Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

VBA DDE WORD EXCEL

// This is just sample code of some dde commands

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
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS