View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
papou[_5_] papou[_5_] is offline
external usenet poster
 
Posts: 4
Default Cannot create object error in Excel 2003

Jack
Did you amend the second option with the relevant sheet name?
Is the sheet protected?
Is the workbook saved in Excel 2003 format?

Apart from that, I can't see so far any other reason why it should not work.
As mentioned, I tested on my pc with Win XP and Excel 2003 and it worked.
Can't test with Xl2007 and Vista.

HTH
Cordially
Pascal

"Jack" a écrit dans le message de news:
...
No luck. Neither worked for me.

Thanks so much for your time!

--
Jack
<<


"papou" wrote:

Hello Jack
If the code is in the sheet module then try:
Me.OLEObjects.Add ClassType:="Forms.CommandButton.1"

Or else in a standard module:
Dim wksPhotos As Worksheet
Set wksPhotos = ThisWorkbook.Worksheets("Photos")
wksPhotos.OLEObjects.Add ClassType:="Forms.CommandButton.1"

Both methods tested successfully in Excel 2003 and Windows XP

HTH
Cordially
Pascal

"Jack" a écrit dans le message de news:
...
I'm getting the error: "Cannot create object" when instantiating a form
commandbutton in Excel 2003 with VBA code. The code works fine in
XL2007.
I
suppose also woth noting is that the XL07 is running under Vista while
XL03
is running under WinXP Pro with the latest SP.

The command that fails is as follows:

wksPhotos.OLEObjects.Add ClassType:="Forms.CommandButton.1"

wlsPhotos is the active worksheet and the statement above is contained
within it.

I've moved the code to module with no change in results.

Any ideas?
--
Jack
<<