Sub RUNEXCELMACRO() 'RUN MACRO aChan = DDEInitiate(App:="Excel", Topic:="System") DDEExecute Channel:=aChan, Command:="[Run(" & Chr(34) & _ "Personal.xls!Macro1" & Chr(34) & ")]" DDETerminate Channel:=aChan 'POKE Chan = DDEInitiate(App:="Excel", Topic:="System") DDEExecute Channel:=Chan, Command:="[OPEN(" & Chr(34) _ & "C:\Sales.xls" & Chr(34) & ")]" DDETerminate Channel:=Chan Chan = DDEInitiate(App:="Excel", Topic:="Sales.xls") DDEPoke Channel:=Chan, Item:="R1C1", Data:="1996 Sales" DDETerminate Channel:=Chan 'This example opens the Microsoft Excel workbook Book1.xls and retrieves the contents of cell R1C1. Chan = DDEInitiate(App:="Excel", Topic:="System") DDEExecute Channel:=Chan, Command:="[OPEN(" & Chr(34) _ & "C:\My Documents\Book1.xls" & Chr(34) & ")]" DDETerminate Channel:=Chan Chan = DDEInitiate(App:="Excel", Topic:="C:\DATA\SBS.xls") msg = DDERequest(Channel:=Chan, Item:="R2C1") msg = msg & " " & DDERequest(Channel:=Chan, Item:="R2C2") MsgBox msg DDETerminateAll 'This example opens a channel to the System topic in Microsoft Excel and then uses the Topics item to return a list of available topics. The example inserts the topic list, which includes all open workbooks, after the selection. aChan = DDEInitiate(App:="Excel", Topic:="System") TOPICLIST = DDERequest(Channel:=aChan, Item:="Topics") Selection.InsertAfter TOPICLIST DDETerminate Channel:=aChan End Sub
You need to create an account or log in to post comments to this site.