Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2006

Tip: Looking for answers? Try searching our database.

How to, check if a picture object exist

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin McCartney - 24 May 2006 16:52 GMT
Hi TWIMC

I wanted to check to ensure a picture logo is present on a worksheet before
I moveit.

So something like

Set oleLOGO1 = wst.pictures("LOGO_1")
If not oleLOGO1 is nothing Then
   'move actions
End

The only problem is what do I declare the oleLOGO as

e.g.

Dim oleLOGO as Excel.OLEObject because I get an error, "Type mismatch".

Any help much appreciated.

TIA
KM
Norman Jones - 24 May 2006 17:05 GMT
Hi Kevin,

Try:

   Dim myPic As Picture

   Set myPic = ws.Pictures("LOGO_1")

---
Regards,
Norman

> Hi TWIMC
>
[quoted text clipped - 19 lines]
> TIA
> KM
Kevin McCartney - 24 May 2006 17:35 GMT
No, that doesn't work, or what library reference are you using?

> Hi Kevin,
>
[quoted text clipped - 31 lines]
> > TIA
> > KM
Norman Jones - 24 May 2006 17:51 GMT
Hi Kevin,

> No, that doesn't work, or what library reference are you using?

My test code was:

'=============>>
Public Sub Tester0012()
   Dim ws As Worksheet
   Dim myPic As Picture

   Set ws = Sheets("Sheet1")

   Set myPic = ws.Pictures("LOGO_1")

   If Not myPic Is Nothing Then
       'do something, e.g,:
       MsgBox myPic.TopLeftCell.Address
   End If

End Sub
'<<=============

---
Regards,
Norman
Norman Jones - 24 May 2006 17:56 GMT
Hi Kevin,

>    Set myPic = ws.Pictures("LOGO_1")

should be:

   On Error Resume Next
   Set myPic = ws.Pictures("LOGO_1")
   On Error GoTo 0

---
Regards,
Norman
Tom Ogilvy - 24 May 2006 18:19 GMT
Why do you think that wouldn't work Kevin?

set ws = Activesheet
? typename(ws.Pictures("LOGO_1"))
Picture

However, if this is actually an image control from the Control Toolbox
Toolbar, then it very well might be an OleObject:

? ws.Pictures(2).Name
CommandButton1
? typename(ws.Pictures(2))
OLEObject

In that case, use the OleObjects collection

If you don't know, then you can

Dim OleLOGO as Object

Signature

Regards,
Tom Ogilvy

> No, that doesn't work, or what library reference are you using?
>
[quoted text clipped - 33 lines]
> > > TIA
> > > KM
Kevin McCartney - 24 May 2006 20:34 GMT
The reason why is that I tried the following but got the same error 13 Type
missmatch

 Dim pic2 As Picture
 
 Set pic2 = wst.Pictures("DB_LOGO_1") it breaks on this line

so if I declare pic2 as picture and if write in the imediate window
?typename(wst.Pictures("DB_LOGO_1")) I do get "Picture" as trhe returned
value, so my problem is why doesn't it work, why does pic2 not get set to
DB_LOGO_1 when DB_LOGO_1 is located on the worksheet.

TIA
KM

> Why do you think that wouldn't work Kevin?
>
[quoted text clipped - 53 lines]
> > > > TIA
> > > > KM
Kevin McCartney - 24 May 2006 20:53 GMT
Oh.... I knew why there was a reason why I shouldn't program late in the
night, I miss the obvious, since I'm running this from Access in needed to
declare the pic as Excel.Picture and not just Picture.... silly me, oh well
another lesson learnd.

Cheers all
TIA
KM

> The reason why is that I tried the following but got the same error 13 Type
> missmatch
[quoted text clipped - 68 lines]
> > > > > TIA
> > > > > KM
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.