DDE Argument exchange with Word

S

Steve

Does anyone know how to send a variable text string from
Excel to Word using a DDE argument in an Excel macro? The
following Excel macro will send a specific text string,
but I want to use a variable to define the text string.



Sub WordOpen(customerName)
'
'

Dim WordApp As Object
Dim WordDoc As Word.Document
Dim Chan As Variant

Dim PathName, FileName As String


PathName = ActiveWorkbook.Path
FileName = PathName & "\Test.doc"


Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open(FileName)
WordApp.Visible = True

' Initiate a channel with Microsoft Word.
Chan = DDEInitiate("WinWord", FileName)

' This sends the text to Word
DDEExecute Chan, "[Module1.Begin(""John Doe"")]"

' Want a command to send variable text customerName to
Word, similar to this except it does not work
' DDEExecute Chan, "[Module1.Begin(customerName)]"

' Terminate the channel.
DDETerminate Chan


'
End Sub
 

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