Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts

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 /


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default CreateObject("Word.Application") fails though Word session starts

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default CreateObject("Word.Application") fails though Word session starts


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default CreateObject("Word.Application") fails though Word session starts

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CreateObject("Word.Application") fails though Word session starts

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
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
CreateObject("InternetExplorer.Application") shart[_9_] Excel Programming 1 January 2nd 06 05:14 PM
Set OutApp = CreateObject("Outlook.Application") - Runtime error 429 Buffyslay Excel Programming 2 July 20th 05 05:06 PM
ASP: CreateObject("Excel.Application") IIS 6.0 Win2003 Mau[_2_] Excel Programming 0 July 20th 05 11:45 AM
Excel VBA, won't recognize "Word.Application" object Skyron Excel Programming 2 May 19th 04 08:48 PM
CreateObject("Excel.Application") - Access denied Luca[_2_] Excel Programming 0 February 6th 04 01:21 PM


All times are GMT +1. The time now is 06:08 AM.

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

About Us

"It's about Microsoft Excel"