Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Shapes.AddPicture - can't make it work

579 views
Skip to first unread message

Andy Clark

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to
Hi,

Excel 97, SR1

I'm upgrading a workbook from Excel 95 to 97, Can anyone tell me why
this doesn't work....?

dim s as shape '--- or object it doesn't help either way
set s = ActiveSheet.ChartObjects(1).Chart.Shapes.AddPicture _
("d:\projects\excel\progresslog\bitmaps\sst.bmp",
_
msoTrue, msoFalse, 10, 10, 24, 12)

I get runtime error 1004, 'application defined or object defined
error'. The failure is in the AddPicture method; I can view the shapes
collection in the watch window.

The bitmap file exists and the path is correct. I can insert it manually
in Excel using 'Insert\Picture\From file...' menu option but it refuses
to work from VBA. Any suggestions greatly appreciated, I've already
spent hours on this!!!

(I also tried InsertOLEObject with similar results. There is no
protection applied to the workbook.)

Thanks
Andy.

(Remove xxx from email address to reply)


Ogilvy, Thomas, W., Mr., ODCSLOG

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to
Andy,

This worked for me:

Sub test12()
Dim s As Shape
Set s = ActiveSheet.ChartObjects(1).Chart.Shapes.AddPicture _
("C:\windows\tiles.bmp", msoTrue, msoFalse, 10, 10, 24, 12)
End Sub

So your syntax is correct for a chart embedded on a worksheet. If you
are running this from a button, try just running it from a common module
with the run command.

HTH,
Tom Ogilvy

Andy Clark

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to
No success yet... but if the syntax is right then the problem is deeper than
I thought,
maybe you can tell me what references you have enabled for VBA in your Excel
setup? It could be I'm missing a crucial DLL ?

Thanks for taking the time to look into this.

Andy

Ogilvy, Thomas, W., Mr., ODCSLOG

unread,
Mar 5, 1999, 3:00:00 AM3/5/99
to
AddPicture and shapes are part of the Excel8.0 object library. That is
pretty straightforward - I don't think you are missing that reference.
However, msoTrue and msoFalse are part of the office 8.0 object library.
Change the arguments to True and False instead or create a reference to
the Office 8.0 object library.

Regards,

Andy Clark

unread,
Mar 6, 1999, 3:00:00 AM3/6/99
to
The Excel 8 library was already referenced, I suspect a problem with my
installation of Excel 97, maybe a DLL referenced by AddPicture was not
updated or has been ovcerwritten. I will try a reinstallation of Office 97.

Thanks.

Thomas Ogilvy

unread,
Mar 6, 1999, 3:00:00 AM3/6/99
to
Changing msoTrue to True and msoFalse to False didn't solve the problem?

Regards,
Tom Ogilvy

Andy Clark wrote in message <36E0F198...@saga.com>...

Andy Clark

unread,
Mar 9, 1999, 3:00:00 AM3/9/99
to
After three unsuccessful reinstallations of Office I finally solved the problem

by manually copying DLL files from the OS folder on the CD to the winnt\
system32 folder.

Some of the files I replaced were newer than the Office versions so I suspect
the that's why the install program didn't replace them. Pity it didn't give a
warning, might have made troubleshooting easier. Now it's a case of waiting
to see what's broken! ('Fraid I don't know exactly which one solved it,
I don't have that much patience!)

One possibility that occurred to me was that I had the Word97 and Excel97
viewers installed before the upgrade to Office 97. These appear to be cut
down versions of the real thing and may have installed crippled, post-dated,
DLLs on my system???

Thanks for the suggestions Tom.

Rgds Andy.

0 new messages