From: Matt Connor on
Hi

I have some code which uses CreateObject

e.g.

Dim XLApp As Object
Set XLApp = CreateObject("Excel.Application")
MsgBox XLApp.Version

On most PCs this works fine but we have 2 new (Win XP) PCs where this
produces Error 91 Object variable or With block variable not set

The error occurs even when logged in with Administrator rights

Also the above example uses Excel but the error ocurs with ANY CreateObject

Any ideas?

Many thanks

Matt



From: Ken Halter on
"Matt Connor" <mattc(a)sytation.com> wrote in message
news:O0s6q$y9FHA.740(a)TK2MSFTNGP11.phx.gbl...
> Hi
>
> I have some code which uses CreateObject
>
> e.g.
>
> Dim XLApp As Object
> Set XLApp = CreateObject("Excel.Application")
> MsgBox XLApp.Version
>
> On most PCs this works fine but we have 2 new (Win XP) PCs where this
> produces Error 91 Object variable or With block variable not set
>
> The error occurs even when logged in with Administrator rights
>
> Also the above example uses Excel but the error ocurs with ANY
> CreateObject
>
> Any ideas?
>
> Many thanks
>
> Matt

Even though your code's late bound, this may help. It's all I could find in
the KB. Google's group search is the next step.

INFO: Error or Unexpected Behavior with Office Automation When You Use Early
Binding in Visual Basic
http://support.microsoft.com/default.aspx?scid=kb;en-us;319832

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm


From: Matt Connor on
Ken

I've already Google'd extensively with no luck.....

Matt


"Ken Halter" <Ken_Halter(a)Use_Sparingly_Hotmail.com> wrote in message
news:uSyhlX19FHA.1332(a)tk2msftngp13.phx.gbl...
> "Matt Connor" <mattc(a)sytation.com> wrote in message
> news:O0s6q$y9FHA.740(a)TK2MSFTNGP11.phx.gbl...
>> Hi
>>
>> I have some code which uses CreateObject
>>
>> e.g.
>>
>> Dim XLApp As Object
>> Set XLApp = CreateObject("Excel.Application")
>> MsgBox XLApp.Version
>>
>> On most PCs this works fine but we have 2 new (Win XP) PCs where this
>> produces Error 91 Object variable or With block variable not set
>>
>> The error occurs even when logged in with Administrator rights
>>
>> Also the above example uses Excel but the error ocurs with ANY
>> CreateObject
>>
>> Any ideas?
>>
>> Many thanks
>>
>> Matt
>
> Even though your code's late bound, this may help. It's all I could find
> in the KB. Google's group search is the next step.
>
> INFO: Error or Unexpected Behavior with Office Automation When You Use
> Early Binding in Visual Basic
> http://support.microsoft.com/default.aspx?scid=kb;en-us;319832
>
> --
> Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
> DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
> Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
>


From: Ken Halter on
"Matt Connor" <mattc(a)sytation.com> wrote in message
news:O4kmhV29FHA.500(a)TK2MSFTNGP15.phx.gbl...
> Ken
>
> I've already Google'd extensively with no luck.....
>
> Matt

fwiw, I just tried pasting this into Notepad (well... UltraEdit32) and saved
it as Test.vbs.... works as expected. XP/SP2 / VB6/SP5+ / Office2003/SP?

>>> Dim XLApp
>>> Set XLApp = CreateObject("Excel.Application")
>>> MsgBox XLApp.Version

You might try running that as script on those "problem" PCs and see how it
goes. If it doesn't work for VB and works for VBS, there may be some DLL
Hell on those machines. If it doesn't work for either, it may be a security
issue (doesn't seem likely if logged on as Admin)

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm


From: MikeD on

"Matt Connor" <mattc(a)sytation.com> wrote in message
news:O0s6q$y9FHA.740(a)TK2MSFTNGP11.phx.gbl...
> Hi
>
> I have some code which uses CreateObject
>
> e.g.
>
> Dim XLApp As Object
> Set XLApp = CreateObject("Excel.Application")
> MsgBox XLApp.Version
>
> On most PCs this works fine but we have 2 new (Win XP) PCs where this
> produces Error 91 Object variable or With block variable not set
>
> The error occurs even when logged in with Administrator rights
>
> Also the above example uses Excel but the error ocurs with ANY
> CreateObject


Not to insult your intelligence or anything, but Excel (and whatever else
you're trying to instantiate using CreateObject) IS properly installed,
right?

Bottom line is really that unless the app is not installed properly, there's
no reason for that code not to work. There could be Registry corruption or
DLL Hell or any of a number of other things, but they all basically boil
down to the app not being installed properly.

--
Mike
Microsoft MVP Visual Basic


 |  Next  |  Last
Pages: 1 2
Prev: Run time error 3021
Next: VBA CODE - ADODB