General information
Category:
COM/DCOM and OLE Automation
>Why would the following sometimes work, and sometimes fail, in Excel 97?
>
>I want to insert a logo into all sheets of an Excel workbook I am creating through Automation. I insert the image with the following commands:
>
> This.oSheet.Cells(tnRow, tnCol).Select()
> This.oSheet.Pictures.Insert(tcFileName)
>
>This is repeated for many different sheets (the property .oSheet changes its value, according to the selected sheet). On some sheets, quite often on the the second sheet, but in general quite randomly, I get an error message, which, translated into English, more or less says: Impossible to obtain property Select of the Range class. The debugger shows me that VFP is trying to execute the first command I listed.
>
>The debugger tells me that tnRow, tnCol and This.oSheet all have valid values.
>
>Any idea, what I might be missing? Perhaps there is a safer way to insert an image in a specific position?
>
In general, you can do pretty much anything without actually selecting. Just work with ranges directly.
I don't see a Pictures collection, so I'm not sure exactly what to suggest, but you should be able to make a range out of the location where you want to insert and then specify that in the insertion.
Tamar
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only