Passing Parameters to Word from Excel

J

jake1729

I need to pass some parameters to Word 2003 from Excel 2003.
Specifically, I to want pass the path of a currently opened Excel fil
to a Word macro. Here is my current code:


Set WordApp = CreateObject(\"Word.Application\") 'Create ne
WordApp object
WordApp.Documents.Open (InspShtDOCLoc) 'Open the specific wordDoc
WordApp.Visible = True 'Set the wordDOC as visible

chanNum = DDEInitiate( _
app:=\"WinWord\", _
topic:=InspShtDOCLoc)

test = ThisWorkbook.FullName 'Path of this Excel file

WordApp.DDEExecute chanNum
\"[GeneralMacros.OpenDataSourceInspect(test)]\"
WordApp.DDETerminate chanNum

I get the filename of the opened Excel file, pass it to a Word Macro
which then sets up a Mail Merge with the Excel file path just passed t
it.

I get the error "Invalid Channel Number"

Any changes (or even a completly different approach) would be very muc
appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top