![]() |
DDE Argument exchange with Word
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 |
All times are GMT +1. The time now is 07:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com