Try this If..Then statement...
If Worksheets("Sheet1").OLEObjects("Image1").Object.P icture Is Nothing Then
--
Rick (MVP - Excel)
"mooresk257" wrote in message
...
OK, thanks - that works. Almost got this thing wrapped up - one more
question
(I hope) on this.
My code for the image box looks like this:
Private Sub Image1_Click()
Dim NewImg As Long
Dim DelImg As Long
NewImg = MsgBox("Insert New Photo?", vbYesNoCancel)
If NewImg = vbYes Then
FileToOpen = Application.GetOpenFilename( _
"All Files (*.jpg),*.jpg, All Files (*.bmp),*.bmp")
If FileToOpen < False Then
Worksheets("Sheet1").OLEObjects("Image1").Object.P icture _
= LoadPicture(FileToOpen)
End If
ElseIf NewImg = vbNo Then
' If Worksheets("Sheet1").OLEObjects("Image1").Object.P icture =
("")
Then
' End If
DelImg = MsgBox("Remove Current Photo?", vbYesNo)
If DelImg = vbYes Then
Worksheets("Sheet1").OLEObjects("Image1").Object.P icture =
LoadPicture("")
ElseIf DelImg = vbNo Then
End If
ElseIf NewImg = vbCancel Then
End If
End Sub
Note the two line I have commented out - I want to skip having the second
message box pop up if the image box is empty, but this line returns an
object
error. So, obviously I've got something wrong somewhere. I only get an
object
error if there is no image in the photo box.
Suggestions?
Also, anyone have a suggestion for a book on VBA? Something written so the
casual user can understand?
"Rick Rothstein" wrote:
Try it this way...
Worksheets("Sheet1").OLEObjects("Image1").Object.P icture =
LoadPicture("")
--
Rick (MVP - Excel)
"mooresk257" wrote in message
...
I posted the code earlier on a different topic:
Private Sub Image1_Click()
FileToOpen = Application.GetOpenFilename( _
"All Files (*.jpg),*.jpg,(*.bmp),*.bmp")
If FileToOpen < False Then
Worksheets("Sheet1").OLEObjects("Image1").Object.P icture _
= LoadPicture(FileToOpen)
End If
End Sub
If I want to remove the image, I have to change the image box Picture
property to "none". Can anyone help with the code for setting
properties?
I think I'd need something like
Worksheets("Sheet1").OLEObjects("Image1").Object.P icture _
= None
Is it possible to assign this to a right-click event? Or, maybe I
should
add
some code for a message box prompting to add or remove an image. I'm
not
sure
what the simplest solution is.
I'm so rusty on VB code - it's been years since I messed with it.
Thanks folks!