Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
We have an Excel application which fails for some users, sometimes,
with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave,
On Apr 2, 5:01 pm, Dave Peterson wrote: I don't know. But maybe a few more questions/answers will help someone else come up with an idea. How did you declare gobjWordApp? Did you declare it as an object (using late binding) or did you add a reference to that workbook's project--and maybe the reference is missing??? What is the error description? 1004 isn't really too helpful. wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for your respones, and your questions.
- I absolutely agree that 1004 isn't a useful error code -- but it's the only one Excel's providing. - The 'objWordApp' object is declared with a "Public Const gobjWordApp as Object" in a separate modeul in the application. Thus it does use late binding. - The idea of a missing reference is interesting. The "Tools / References" within VBE look normal. And I can easily create the Word session, just not (always) get it assigned to an Excel variable. Is there something I'm missing here, that I'm not checking but should? / T / On Apr 2, 5:01 pm, Dave Peterson wrote: I don't know. But maybe a few more questions/answers will help someone else come up with an idea. How did you declare gobjWordApp? Did you declare it as an object (using late binding) or did you add a reference to that workbook's project--and maybe the reference is missing??? What is the error description? 1004 isn't really too helpful. wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I still don't have a guess.
But when you see that 1004 error, what's the error description that you see? Marchand wrote: Thanks for your respones, and your questions. - I absolutely agree that 1004 isn't a useful error code -- but it's the only one Excel's providing. - The 'objWordApp' object is declared with a "Public Const gobjWordApp as Object" in a separate modeul in the application. Thus it does use late binding. - The idea of a missing reference is interesting. The "Tools / References" within VBE look normal. And I can easily create the Word session, just not (always) get it assigned to an Excel variable. Is there something I'm missing here, that I'm not checking but should? / T / On Apr 2, 5:01 pm, Dave Peterson wrote: I don't know. But maybe a few more questions/answers will help someone else come up with an idea. How did you declare gobjWordApp? Did you declare it as an object (using late binding) or did you add a reference to that workbook's project--and maybe the reference is missing??? What is the error description? 1004 isn't really too helpful. wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / -- Dave Peterson -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dave,
On Apr 2, 5:58 pm, Dave Peterson wrote: I still don't have a guess. But when you see that 1004 error, what's the error description that you see? Marchand wrote: Thanks for your respones, and your questions. - I absolutely agree that 1004 isn't a useful error code -- but it's the only one Excel's providing. - The 'objWordApp' object is declared with a "Public Const gobjWordApp as Object" in a separate modeul in the application. Thus it does use late binding. - The idea of a missing reference is interesting. The "Tools / References" within VBE look normal. And I can easily create the Word session, just not (always) get it assigned to an Excel variable. Is there something I'm missing here, that I'm not checking but should? / T / On Apr 2, 5:01 pm, Dave Peterson wrote: I don't know. But maybe a few more questions/answers will help someone else come up with an idea. How did you declare gobjWordApp? Did you declare it as an object (using late binding) or did you add a reference to that workbook's project--and maybe the reference is missing??? What is the error description? 1004 isn't really too helpful. wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / -- Dave Peterson -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See http://tinyurl.com/yp95cb
HTH, JP On Apr 2, 7:17*pm, wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: * * * * * * *Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. * * Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. * * Re-installing Office doesn't change anything. * * The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. * * There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. * * * Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Why do you declare your Word Object as a constant? I do not see any reason so far with the info you provided. In addition there is obviously a mistake in this line: Public Const gobjWordApp as Object Can you just try and change to: Public objWordApp As Object And see if it works? HTH Cordially Pascal "Marchand" a écrit dans le message de news: ... Thanks for your respones, and your questions. - I absolutely agree that 1004 isn't a useful error code -- but it's the only one Excel's providing. - The 'objWordApp' object is declared with a "Public Const gobjWordApp as Object" in a separate modeul in the application. Thus it does use late binding. - The idea of a missing reference is interesting. The "Tools / References" within VBE look normal. And I can easily create the Word session, just not (always) get it assigned to an Excel variable. Is there something I'm missing here, that I'm not checking but should? / T / On Apr 2, 5:01 pm, Dave Peterson wrote: I don't know. But maybe a few more questions/answers will help someone else come up with an idea. How did you declare gobjWordApp? Did you declare it as an object (using late binding) or did you add a reference to that workbook's project--and maybe the reference is missing??? What is the error description? 1004 isn't really too helpful. wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() My apoligies for some of the misingofmation in this thread from a well- meaning colleague. The relevant code surrounding the problem is Dim gobjWordAPp as Object '... set gobjWordAPp = CreateObject("Word.Application") THe 1004 error message is the very generic "Run time error 1004" with no further details JP, thanks for the link. I've never used the second parameter of CreateObject() but will try it and see, and get back to this thread with the results. / Tyla / On Apr 2, 4:17 pm, wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
But you're positive that MSWord is started???
I'd use: on error resume next set gobjWordAPp = CreateObject("Word.Application") if err.number < 0 then msgbox "something bad happened" err.clear exit sub '???? end if on error goto 0 But that just masks the error--it doesn't explain why MSWord is really started. I still don't have a guess for that. wrote: My apoligies for some of the misingofmation in this thread from a well- meaning colleague. The relevant code surrounding the problem is Dim gobjWordAPp as Object '... set gobjWordAPp = CreateObject("Word.Application") THe 1004 error message is the very generic "Run time error 1004" with no further details JP, thanks for the link. I've never used the second parameter of CreateObject() but will try it and see, and get back to this thread with the results. / Tyla / On Apr 2, 4:17 pm, wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / -- Dave Peterson |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not sure if this applies to your application, but if the code still
won't work, you can try early binding. You would just add code like this to the ThisWorkbook module to check if there is a reference to the Word object library when the workbook opens. If not, the code creates one. (this is air code from memory, please test first) Dim bWasFound As Boolean Private Sub Workbook_Open() For i = 1 To ThisWorkbook.VBProject.References.Count If ThisWorkbook.VBProject.References.Item(i).Name = "Word" Then ' Not sure if the name of the library is "Word" bWasFound = True Exit Sub End If Next i If bWasFound = False Then ThisWorkbook.VBProject.References.AddFromFile _ "C:\Program Files\Microsoft Office\Office10\MSWORD.OLB" End If End Sub Then you could use this code (adapted from http://www.dicks-clicks.com/excel/olBinding.htm) to set a reference to the Word Application object. Dim wdApp As Word.Application On Error Resume Next Set wdApp = GetObject(, "Word.Application") If Err.Number < 0 Then Set wdApp = CreateObject("Word.application") End If On Error GoTo 0 If wdApp Is Nothing then msgbox "Cannot start Word", vbCritical Exit Sub End if In the Workbook_BeforeClose you can remove the reference if you wish. HTH, JP On Apr 3, 11:18*am, wrote: My apoligies for some of the misingofmation in this thread from a well- meaning colleague. The relevant code surrounding the problem is * * * * Dim gobjWordAPp as Object * * * * '... * * * * set gobjWordAPp = CreateObject("Word.Application") THe 1004 error message is the very generic * * * * "Run time error 1004" with no further details JP, thanks for the link. I've never used the second parameter of CreateObject() but will try it and see, and get back to this thread with the results. / Tyla / On Apr 2, 4:17 pm, wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: * * * * * * *Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. * * Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. * * Re-installing Office doesn't change anything. * * The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. * * There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. * * * Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla /- Hide quoted text - - Show quoted text - |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yup -- Word definitely starts. There's WINWORD.exe process showing as
running in Task Manager after CreateObject() executes. I'll play with the 'on error' code see if I can tease out any more details. On Apr 3, 10:32 am, Dave Peterson wrote: But you're positive that MSWord is started??? I'd use: on error resume next set gobjWordAPp = CreateObject("Word.Application") if err.number < 0 then msgbox "something bad happened" err.clear exit sub '???? end if on error goto 0 But that just masks the error--it doesn't explain why MSWord is really started. I still don't have a guess for that. wrote: My apoligies for some of the misingofmation in this thread from a well- meaning colleague. The relevant code surrounding the problem is Dim gobjWordAPp as Object '... set gobjWordAPp = CreateObject("Word.Application") THe 1004 error message is the very generic "Run time error 1004" with no further details JP, thanks for the link. I've never used the second parameter of CreateObject() but will try it and see, and get back to this thread with the results. / Tyla / On Apr 2, 4:17 pm, wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla / -- Dave Peterson |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() For what it's worth... Each user must have a copy of Word installed. Also, as far as I can see, you haven't specified the office versions involved. If it is both 2007 and prior versions, then you might ask in a Word newsgroup, if Word 2007 is compatible with prior versions when using automation? -- Jim Cone San Francisco, USA http://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
JP,
I've been reluctant to go for early binding, since it makes assumptions about the users machines I can't always depend on (this is a commercial app). The ability to programmatcially reference the VBEProject is virtually nil due to security settins. Users can also have various version of Word, making a hard-wired "AddFromFile" pretty dicey. Is there a way to assert a reference baed on GUID rather than file name? / T / On Apr 3, 11:04 am, JP wrote: Not sure if this applies to your application, but if the code still won't work, you can try early binding. You would just add code like this to the ThisWorkbook module to check if there is a reference to the Word object library when the workbook opens. If not, the code creates one. (this is air code from memory, please test first) Dim bWasFound As Boolean Private Sub Workbook_Open() For i = 1 To ThisWorkbook.VBProject.References.Count If ThisWorkbook.VBProject.References.Item(i).Name = "Word" Then ' Not sure if the name of the library is "Word" bWasFound = True Exit Sub End If Next i If bWasFound = False Then ThisWorkbook.VBProject.References.AddFromFile _ "C:\Program Files\Microsoft Office\Office10\MSWORD.OLB" End If End Sub Then you could use this code (adapted fromhttp://www.dicks-clicks.com/excel/olBinding.htm) to set a reference to the Word Application object. Dim wdApp As Word.Application On Error Resume Next Set wdApp = GetObject(, "Word.Application") If Err.Number < 0 Then Set wdApp = CreateObject("Word.application") End If On Error GoTo 0 If wdApp Is Nothing then msgbox "Cannot start Word", vbCritical Exit Sub End if In the Workbook_BeforeClose you can remove the reference if you wish. HTH, JP On Apr 3, 11:18 am, wrote: My apoligies for some of the misingofmation in this thread from a well- meaning colleague. The relevant code surrounding the problem is Dim gobjWordAPp as Object '... set gobjWordAPp = CreateObject("Word.Application") THe 1004 error message is the very generic "Run time error 1004" with no further details JP, thanks for the link. I've never used the second parameter of CreateObject() but will try it and see, and get back to this thread with the results. / Tyla / On Apr 2, 4:17 pm, wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. Re-installing Office doesn't change anything. The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla /- Hide quoted text - - Show quoted text - |
#15
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jim, Good points, all of them. We support Word 2000 and above and
basically don't care beyond that. I've been reluctant to cross-post this issue, but that's definitely a possibility. /Tyla / On Apr 3, 11:28 am, "Jim Cone" wrote: For what it's worth... Each user must have a copy of Word installed. Also, as far as I can see, you haven't specified the office versions involved. If it is both 2007 and prior versions, then you might ask in a Word newsgroup, if Word 2007 is compatible with prior versions when using automation? -- Jim Cone San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware (Excel Add-ins / Excel Programming) |
#16
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Did you test out the code in that link I sent you? Apparently, some AV
programs have script stoppers that might affect the code. I guess at this point all I can think of is that there is something about your code environment causing this issue, but I can't identify it because I'm not there. You might inadvertently be leaving out some lines of code, environmental variables, or other parameters that seem inocuous but would help identify the cause. Sorry I couldn't be more help here. --JP On Apr 3, 2:29*pm, wrote: JP, * * * * I've been reluctant to go for early binding, since it makes assumptions about the users machines I can't always depend on (this is a commercial app). The ability to programmatcially reference the VBEProject is virtually nil due to security settins. Users can also have various version of Word, making a hard-wired "AddFromFile" pretty dicey. Is there a way to assert a reference baed on GUID rather than file name? / T / On Apr 3, 11:04 am, JP wrote: Not sure if this applies to your application, but if the code still won't work, you can try early binding. You would just add code like this to the ThisWorkbook module to check if there is a reference to the Word object library when the workbook opens. If not, the code creates one. (this is air code from memory, please test first) Dim bWasFound As Boolean Private Sub Workbook_Open() * * For i = 1 To ThisWorkbook.VBProject.References.Count * * * * If ThisWorkbook.VBProject.References.Item(i).Name = "Word" Then ' Not sure if the name of the library is "Word" * * * * * bWasFound = True * * * * * Exit Sub * * * * End If * * Next i If bWasFound = False Then * * ThisWorkbook.VBProject.References.AddFromFile _ * * "C:\Program Files\Microsoft Office\Office10\MSWORD.OLB" End If End Sub Then you could use this code (adapted fromhttp://www.dicks-clicks.com/excel/olBinding.htm) to set a reference to the Word Application object. Dim wdApp As Word.Application On Error Resume Next Set wdApp = GetObject(, "Word.Application") * * If Err.Number < 0 Then * * * * Set wdApp = CreateObject("Word.application") * * End If On Error GoTo 0 If wdApp Is Nothing then * * msgbox "Cannot start Word", vbCritical * * Exit Sub End if In the Workbook_BeforeClose you can remove the reference if you wish. HTH, JP On Apr 3, 11:18 am, wrote: My apoligies for some of the misingofmation in this thread from a well- meaning colleague. The relevant code surrounding the problem is * * * * Dim gobjWordAPp as Object * * * * '... * * * * set gobjWordAPp = CreateObject("Word.Application") THe 1004 error message is the very generic * * * * "Run time error 1004" with no further details JP, thanks for the link. I've never used the second parameter of CreateObject() but will try it and see, and get back to this thread with the results. / Tyla / On Apr 2, 4:17 pm, wrote: We have an Excel application which fails for some users, sometimes, with a 1004 at the line: * * * * * * *Set gobjWordApp = CreateObject("Word.Application") where gobjWordApp has been defined as an Object. What's interesting is that the Word session has been started, as per Task Manager. It isn't visible to the user at that point (as expected) and the gobjWordApp object is undefined.. So while Word is there, it looks like the reference/pointer back to VBA simply doesn't occur. * * Additional hints: Changing the line to a simple "CreateObject("Word.Application") works fine -- although it's pretty useless for the application since there's no addressable object for VBA to interact with. * * Re-installing Office doesn't change anything. * * The typical environment is Windows XP/SP2 and Office 2003/SP2 or SP3. * * There doesn't seem to be a particular pattern in terms of who this works for and who it fails for, although we're getting suspicious of the new Vista-compatible versions of HP printer drivers. * * * Has anyone had experience with this kind of problem or, even better, know of a fix? / Tyla /- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
#17
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not sure if you got this resolved.. but I'm having a similar problem and
I'm calling createobject("Word.Application") from VB...check out this article http://support.microsoft.com/kb/828550 *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CreateObject("InternetExplorer.Application") | Excel Programming | |||
Set OutApp = CreateObject("Outlook.Application") - Runtime error 429 | Excel Programming | |||
ASP: CreateObject("Excel.Application") IIS 6.0 Win2003 | Excel Programming | |||
Excel VBA, won't recognize "Word.Application" object | Excel Programming | |||
CreateObject("Excel.Application") - Access denied | Excel Programming |