Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List of commands for DDE with Excel and Word 1

Status
Not open for further replies.

mflancour

MIS
Apr 23, 2002
379
US
Good morning all. I want to use DDE to communicate with excel and Word through access but cannot find a list of the commands that word and excel will accept. Below are two exampls to clerify:

DDEExecute intChan1, "[New(1)]"


DDEExecute intChan1, "[Select(""R1C1:R1C10"")][New(2,2)]"

These were shown in Acces help...In specific i am looking for the string that will let me call a macro for both word and excel from acces.
 
I don't remember where I got the topics from when I did this sort of thing 7 or 8 years ago. Any reason why you don't want to use the much easier and much more reliable OLE Automation? JHall
 
No reson at all.....This is just the one I ran accros first when looking for a way to do this. Can you give me a code for OLE opening word or excel then running a macro?
 
Under tools in your code module References, check Microsoft Word Object library.

Then in your code in declarations
Dim MyWord as Word.Application


In a procedure or function

Set MyWord = New Word.Application
MyWord.Run "MacroNamegoesHere", "argument1", "argument2", etc
JHall
 
Ok, so this works great...except i need to open a file previous to runing the macro. I know this must be simple but everything i try seems to be runing the macro before the file finishes loading.
 
Hmm, I seem to remember it goes a bit like:

Dim m_objWord As Word.Application
Dim m_objDoc As Word.Document

Set m_objWord = New Word.Application
m_objWord.Visible = True

Set m_objDoc = m_objWord.Documents.Add(m_strDIR & m_strFILE)


Substitute m_strDIR for the direcotry of the file in string format and m_strFILE as the filename. ie.

Dim m_objWord As Word.Application
Dim m_objDoc As Word.Document
dim m_strDIR as String
dim m_strFILE as String

Set m_objWord = New Word.Application
m_objWord.Visible = True ' Makes Word Visible

Set m_objDoc = m_objWord.Documents.Add(m_strDIR & m_strFILE)

m_strDIR="C:\Temp\"
m_strFILE="Letter.DOC"


So this would give you a Word App, make it visible and loads C:\Temp\letter.doc.



Hope it helps

Tim

PS As before, make sure the correct Word Library has been added in to your References.

PPS Have a look in the object browser in the VBA window, change the library from All to Word and search for Open, or Save, etc... as requried. Once you find an object and method/proeprty that looks useful, right mouseclick on select help. Always works for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top