Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Word Automation help

Word Automation help

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++databasetesting
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    C NewBe
    wrote on last edited by
    #1

    Can someone guide me on how to add text to a word document using "Bookmarks" from a word template "file.dot". I started with the visual C++ code below but I get lost trying to follow the Microsoft Word Objects schema, I just don't know how to tie it in like the VB example. Visual Basic example code ___________________________________________________ Set wrdApp = CreateObject("Word.Application") wrdApp.Documents.Open("c:\file.dot") wrApp.ActiveDocumnet.Bookmarks("String One").Range.Text = "Vb sample" ________end of VB example____________________________________________________ Visual C++ __________________ void SystemAlign::CreateDoc(void) { CApplication oApp; CBookmarks oBooks; Cbookmark oBook; CDocuments oDocs; Cdocument oDoc; CRange oRange; COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR), vtTrue((short)TRUE), vtFalse((short)FALSE); // Create an instance of Word if (!oApp.CreateDispatch("Word.Application")) { AfxMessageBox("Word failed to start!"); return; } oDocs = oApp.get_Documents(); oDoc = oDocs.Open("c:\My Documents\file.dot", vtOptional); oBooks = oApp.get_ActiveDocument(); //oApp.get_ActiveDocument() }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups