LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default Populate Bookmarkes in a Word Doc. with Excel

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pulling information from Word to populate into Excel Melanie Tatasciore Excel Discussion (Misc queries) 1 October 9th 09 07:09 PM
Excel Macro to Auto-Populate a Word Template Dan Thorman Excel Programming 4 January 26th 07 08:48 PM
How can I have Excel cells populate a Word label template? MS Questionnairess Excel Discussion (Misc queries) 1 June 8th 06 01:26 AM
Populate word doc with excel data peter.thompson[_34_] Excel Programming 1 January 10th 06 02:12 AM
Link a form field in a Word document to populate an excel spreads andrealdv Excel Discussion (Misc queries) 0 August 29th 05 09:47 PM


All times are GMT +1. The time now is 02:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"