View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
rjr rjr is offline
external usenet poster
 
Posts: 50
Default Open WORD Doc and assign Excel tab as data source for merge.

Hello,
I am using Excel 2003 and Windows XP Pro on my machine. I have a workbook
that has a tab named "Database". This "Database" is used to provide
information for WORD documents (merge letters) for a mail merge. I need Code
to run from the Excel workbook that will open the specific WORD merge letter
and assign the datasource tab without seeing a message box or prompt.
I found this and it opens the actual document but stops there. WHen I run
this I get the message box to select the tab where the data is located.

My data is contained in the Excel workbook that is active, and the data is
contained in a tab "Database"

I don't want to have to select the data base each time and all files will be
fixed and no variation in the name.

Any Help would be greatly appreciated,

BOB REYNOLDS


Sub OpenWordDoc()
Dim wdApp As Word.Application, wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number < 0 Then 'Word isn't already running
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Set wdDoc =
wdApp.Documents.Open("C:\LettersFormsCOJMaster\Let ters01232007\L06Closurewithpayment01232007.dot")
'This path is fixed and will not vary.
wdApp.Visible = True
End Sub