Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Im trying to push several values from an Excel sheet into a Word document,
using VBA in Excel and bookmarks in Word. Below is what I have so far: Sub PushToWord() Dim objWord As New Word.Application Dim doc As Word.Document Dim bmk As Word.Bookmark Set doc = objWord.Documents.Open("C:\Test\Disclosure.doc") For Each bmk In doc.Bookmarks If bmk.Name = "BrokerFirstName" Then bmk.Range.Text = ActiveWorkbook.Sheet("LOOKUP").Range("B1").Value If bmk.Name = "BrokerLastName" Then bmk.Range.Text = ActiveWorkbook.Sheet("LOOKUP").Range("B2").Value Next 'doc.Bookmarks("First_Name").Range.Text = Range("A1").Value objWord.Visible = True End Sub The sheet with all the values is called LOOKUP and the ranges are pretty obvious. What I cant figure out, is the following: The macro will run from an Excel file, which will essentially be the ActiveWorkbook, but Im not sure how to tell Word that the data is coming first from the ActiveWorkbook, and then from the sheet named LOOKUP, and finally from specific cells. Do I even need ActiveWorkbook in there? As it is written now, I can open a Word template from a specific location, but I want to be able to open any one of a couple dozen Word files (not a loop; just open it and let Excel know that this is the active document, with bookmarks, that need to be updated) from many locations. Thus, I am trying to incorporate the following line of code into the macro: file = Application.GetOpenFilename Does anyone have any ideas about the best way to set this up? I am thinking it is not difficult at all€¦just cant get my mind around it right now€¦ Regards, Ryan-- -- RyGuy |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pulling information from Word to populate into Excel | Excel Discussion (Misc queries) | |||
Excel Macro to Auto-Populate a Word Template | Excel Programming | |||
How can I have Excel cells populate a Word label template? | Excel Discussion (Misc queries) | |||
Populate word doc with excel data | Excel Programming | |||
Link a form field in a Word document to populate an excel spreads | Excel Discussion (Misc queries) |