View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
papou[_9_] papou[_9_] is offline
external usenet poster
 
Posts: 52
Default Controlling Word from Excel

Hi Paul
Some slight amendments/suggestions:
1 - objWord.Activate is not necessary
2 - What is the ChangeFileOpenDirectory?
I would suggest that this is not necessary since you could include the path
in: the opening process.
3 - When opening the file you are not using the objWord so this may be the
reason for its not working properly.
Therefore I would suggest:
objWord.Documents.Open Filename:="M:\Finance\General\Management_
Information\Extras\XL Tips.doc"

HTH
Cordially
Pascal

"Paul Haywood" a écrit dans le message de
om...
Thanks for your reply and this does help but I'm having inconsistent
results opening the Word document, sometimes it opens and sometimes it
doesn't. I have included the code for your perusal. Any help would
be greatly appreciated.

Sub Open_Tips()

On Error Resume Next

Set objWord = GetObject(, "Word.Application")

If Err < 0 Then Set objWord = CreateObject("Word.Application")

objWord.Visible = True
objWord.Activate

ChangeFileOpenDirectory "M:\Finance\General\Management
Information\Extras\"
Documents.Open Filename:="""XL Tips.doc""",
ConfirmConversions:=False, _
ReadOnly:=True, AddToRecentFiles:=False, PasswordDocument:="",
_
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto

objWord = Nothing

End Sub

Regards

"papou" wrote in message

...
Hi Paul
On Error Resume Next
Set objWord = GetObject(, "Word.Application")
If Err < 0 Then Set objWord = CreateObject("Word.Application")

HTH
Cordially
Pascal

"Paul Haywood" a écrit dans le message de
om...
I am trying to open a Word document from a toolbar I have constructed
in Excel.

I would like my code to check to see whether an instance of Word is
already running and if so just open the document specified in
'Documents.Open Filename:="

I'm having quite a bit of trouble with this at the moment so any help
would be appreciated.

Thanks