Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to open a specific Word file from excel but It doesn't work when i use GetObject
I can get word to instantiate when i use CreateObject, example Set Wrd = CreateObject("Word.Application" Wrd.Visible = Tru but beyond that I can't get the neccessary file to load. I tried using Set Wrd = GetObject(MyFilePath, "word.application") where MyFilePath is a string with the file path and file name. But I get error # 432: "filename or class name not found during automation operation". And if i try it without using a class name, because the documentation saids it should default to the proper class based on the file name's extension, i get nothing. can someone who is familiar with this please help. Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
GetObject will only work if Word is already running.
Also, the first argumen t is the pathnamje of the object being retrieved, which is Word, notv the file. To get the file you need Set wrd = GetObject(, "word.application") Set myDoc = GetObject(myFilePath) -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "chris" wrote in message ... I am trying to open a specific Word file from excel but It doesn't work when i use GetObject. I can get word to instantiate when i use CreateObject, example: Set Wrd = CreateObject("Word.Application") Wrd.Visible = True but beyond that I can't get the neccessary file to load. I tried using: Set Wrd = GetObject(MyFilePath, "word.application") where MyFilePath is a string with the file path and file name. But I get error # 432: "filename or class name not found during automation operation". And if i try it without using a class name, because the documentation saids it should default to the proper class based on the file name's extension, i get nothing. can someone who is familiar with this please help. Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub test()
Dim wrd As Object Set wrd = CreateObject("Word.Application") wrd.Visible = True wrd.Documents.Open "C:\T\Doc1.doc" End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "chris" wrote in message ... I am trying to open a specific Word file from excel but It doesn't work when i use GetObject. I can get word to instantiate when i use CreateObject, example: Set Wrd = CreateObject("Word.Application") Wrd.Visible = True but beyond that I can't get the neccessary file to load. I tried using: Set Wrd = GetObject(MyFilePath, "word.application") where MyFilePath is a string with the file path and file name. But I get error # 432: "filename or class name not found during automation operation". And if i try it without using a class name, because the documentation saids it should default to the proper class based on the file name's extension, i get nothing. can someone who is familiar with this please help. Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chri
This works in Excel 2002: I added a reference to Microsoft Word 10.0 Object Library so I could be more specific in my Dim statement, but it may be possible to do it without that. I think the secret is to open Word first and then load he doc Sub testOpenWord( Dim wrd As Word.Applicatio Const cWrdDoc = "E:\Master Code\Code for XXX 040112.doc" 'YOUR FILE PATH HER Set wrd = GetObject(, "Word.Application" 'Set wrd = GetObject(cWrdDoc, "Word.Application" If Err.Number = 429 The Set wrd = CreateObject("Word.Application" Err.Number = End I wrd.Visible = Tru wrd.Documents.Open Filename:=cWrdDo 'et 'et End Su |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chri
I meant to put "NOT" in front of the comment lin 'Set wrd = GetObject(cWrdDoc, "Word.Application" as in 'Not Set wrd = GetObject(cWrdDoc, "Word.Application" Rog |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found the simplest way was to create a hyperlink to the
document in a cell. You can activate it by the following - Worksheets("SheetName").Range ("WhereHyperlinkIs").Hyperlinks.Item(1).Follow -----Original Message----- I am trying to open a specific Word file from excel but It doesn't work when i use GetObject. I can get word to instantiate when i use CreateObject, example: Set Wrd = CreateObject("Word.Application") Wrd.Visible = True but beyond that I can't get the neccessary file to load. I tried using: Set Wrd = GetObject(MyFilePath, "word.application") where MyFilePath is a string with the file path and file name. But I get error # 432: "filename or class name not found during automation operation". And if i try it without using a class name, because the documentation saids it should default to the proper class based on the file name's extension, i get nothing. can someone who is familiar with this please help. Thanks . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Opening a Word Document using an Excel (2000) Macro? | Excel Discussion (Misc queries) | |||
opening word document | Excel Discussion (Misc queries) | |||
Opening word document through excel vba | Excel Discussion (Misc queries) | |||
Opening Word Document with excel | Excel Discussion (Misc queries) | |||
Opening a Word Document in Excel | Excel Programming |