Best method to OPEN and send instructions to Word 2000 from Acces.

G

Guest

Can anybody please help me open Word 2000 from within Access 2000 and send
instructions to Word. I used to use the Sendkeys method in Access 98 but am
experiencing difficulties with Access 2000. I open Word with:-
Call Shell("Winword.exe"),vbMaximizeFocus
Sendkeys "{Enter 4}" etc.
Two instances of Word open and the instructions are duplicated on one
document.
 
T

Tim Ferguson

Can anybody please help me open Word 2000 from within Access 2000 and
send instructions to Word.

I used to use the Sendkeys method

SendKeys is nearly always doomed to failure: it's a desperate remedy best
reserved for the very worst cases and even then there have to be other
ways round...

For manipulating Word, far and away the best method is OLE automation:

Dim wdApp As Object
Dim docTemp as Word.Document

' create a new Word application
Set wdApp = GetObject(,"winword.application")

' make a new document
With wdApp.Documents.Add( "MyBestTemplate", etc, etc )
' write some stuff
.InsertAfter "Hello, mum"

' print it out
.PrintOut

' close it
.Close wdDontSaveFirst

End With

' and close the application
wdApp.Quit


More help in almost any book on Office automation etc.

Hope that helps


Tim F
 
G

Guest

Very nice. I've been looking for this type of syntax for Outlook and a new
email.

Does someone have a very basic example of an Outlook new email generated by
Access with this type of automation.
 
A

Alex White MCDBA MCSE

best advice I can give on automating either Word or Excel is this,

go into Word/Excel, record a macro, try to manually to what you are trying
to automate, stop the recording, view the macro, cut and paste the macro
code into your access code/module, make a few little changes and automation
from access to Word/Excel.

You have to declare the word.application as below before your cut/paste of
the word macro.
 
T

Tim Ferguson

Does someone have a very basic example of an Outlook new email
generated by Access with this type of automation.

For very obvious reasons, MS make it very hard to automate outlook from any
kind of scripting language. Some may say that it's come fifteen years too
late, but what would I know. You will need a digital certificate or some
kind of kludge to get round the user warning message boxes.

That having been said, the Outlook object model is in the help files, so
you can work most of it out. You could also try googling or looking in one
of the outlook newsgroups.

Hope that helps


Tim F
 

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