Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Controlling Word from Excel

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default Controlling Word from Excel

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Controlling Word from Excel

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Controlling word wrap in a cell Victor Delta[_2_] Excel Discussion (Misc queries) 2 February 14th 10 10:58 PM
Controlling Word from Excel tonesmcbutt Excel Programming 1 January 7th 04 09:21 PM
Controlling Word template from Excel Lee Excel Programming 1 November 9th 03 11:50 AM
Controlling Outlook from Excel Using VBA Trevor Shuttleworth Excel Programming 1 September 9th 03 10:43 PM
controlling another program from Excel Steve Smallman Excel Programming 1 August 1st 03 03:01 PM


All times are GMT +1. The time now is 09:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"