Problem running external apps

S

simon

i need to opn a mailmerged doc from with Access vba. I have found 2
ways of doing this,

Firstly, i can use the SHELL command but it doesnt like the directory
structure and i cannot get arround this.....

Shell ("c:\program files\microsoft office\office11\winword.exe S:
\Quarles Support Unit\QSU Databases\Simon\new.doc") It opens
winword.exe but has an issue with the long file names & spaces with
the acual document


The other way is to open it with code, but when i do this the
mailmergetoolbar is greyed out. Now, i am sure i have thecode
wrong........

Dim oApp As Object
Dim pos As Integer
Dim filename As String
pos = InStrRev(CurrentDb.Name, "\")
'filename = "S:\Quarles Support Unit\QSU Databases\simon\new.doc"

Set oApp = CreateObject("word.application")
oApp.Visible = True
Set objWord = CreateObject("word.basic")
objWord.fileopen filename



Please please please can someone end my suffering here? it is causing
a real headache. Maybe there is a different way altogether t do this?

Many thanks in advance
 
S

simon

oh man!!!! can it really be that simple????

i cant hank you enough, works well. much appreciated
 
S

simon

This works really well. only problem is that from time to time word
crashes, which holds the document open even though it is not in use.
is there any reason for this?

Or does anyone have a better way of doing it?
 

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