Run-time error 1004, Unable to get Object Property of OLEObject class

MarcPop

New Member
Joined
Feb 10, 2011
Messages
6
Hi,
I hope that someone knows the solution to this one.
I have written a macro in excel 2007 which runs a database query with some user selected criteria and consequently fills some graphs and tables on a sheet.
As part of the project it also updates and adds items in a couple of OLEObjects (comboboxes).

This is working fine and I tested on different other pc’s. On one pc however it does not work and crashes on the code referring to the OLEObjects with the error:


Run-time error 1004, Unable to get Object Property of OLEObject class

It crashes on the first line of the following code:

Set cboTemp = ws.OLEObjects("ComboSalesman")

With cboTemp
.ListFillRange = "Salesman"
.Object.ListIndex = 0
End With

After this more code follows referring to other objects and if I test those the same error appears on that one pc only. Of course this is the pc of the designated user of the report L.
On all pc’s I am using Excel 2007. I have checked to see if maybe some libraries (references) where not set on the pc where the code is not working but that seems fine (as it should be).

What can cause this code to crash on one pc only?
Help is much appreciated!
Marc<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I had a similar experience with a Word document embedded in a worksheet: it worked on my office machine and a friend's machine but not on my home machine. After some Googling I came across advice on MSDN to refer to the object by its index number, so:-
Code:
[FONT=Verdana][COLOR=black]Set cboTemp = ws.OLEObjects(1)[/COLOR][/FONT]
If you don't know the index number, you might need to do something like this to find out:-
Code:
For Each cboTemp In ws.OLEObjects
   Debug.Print cboTemp.Index, cboTemp.Name
Next cboTemp
(Untested.)

That actually didn't work for me but someone else suggested .Activateing the object first, and that did work.

Try:-
Code:
ws.OLEObjects("ComboSalesman").Activate
Set cboTemp = ws.OLEObjects("ComboSalesman")

Just a shot in the dark...
 
Upvote 0
Thanks for your reply Ruddles.
Unfortunately it didn't work.
I already tried using the index number and that didn't work.

When activating the object first, I get the following error :
1004: Cannot activate source file object.

Both options of course work on other pc's.
It seems excel does not seem to be able to locate the Oleobjects on this pc.
To make it more interesting, when logged in on this pc with my own username it works fine again.

:eek:
 
Upvote 0
How about ...
Code:
    With Sheet1.ComboSalesman
        .ListFillRange = "Salesman"
        .ListIndex = 0
    End With
 
Upvote 0
How about ...
Code:
    With Sheet1.ComboSalesman
        .ListFillRange = "Salesman"
        .ListIndex = 0
    End With

Thanks shg4421, but unfortunately this didn't work either.
Same error message as earlier:

Run-time error 1004, Unable to get Object Property of OLEObject class
 
Upvote 0
Works for me in both 2003 and 2007 on XP. I reckcon that's not a surprise considering you only have a problem with one computer.

Shooting in the dark, and a variation on Ruddles suggestion,

Code:
    With Sheet1.OLEObjects(Sheet1.ComboSalesman.Index)
        .ListFillRange = "Salesman"
        .Object.ListIndex = 0
    End With
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top