Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Controlling word wrap in a cell | Excel Discussion (Misc queries) | |||
Controlling Word from Excel | Excel Programming | |||
Controlling Word template from Excel | Excel Programming | |||
Controlling Outlook from Excel Using VBA | Excel Programming | |||
controlling another program from Excel | Excel Programming |