Excel 2010 Crashing when select to insert picture

dcoledc

Active Member
Joined
May 6, 2010
Messages
403
Does anyone see any problems or know of any problems with using this code in Excel 2010 to select an image to insert?

Code:
myPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif),*.gif; *.jpg; *.bmp; *.tif", , "Select Picture to Import")
If myPicture = "False" Then Exit Sub

This code seems to cause Excel 2010 to crash at random. It works sometmes with no problems at all and then suddenly it crashes Excel. Again this is only happening in 2010.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
As far as I can see, your code seems fine. And, I've tested it a number of times on Excel 2010 and had no problems.
 
Upvote 0
Just a thought, If myPicture = "False" Then Exit Sub plays only if myPicture is declared As String variable.
Check this declaration in the code: Dim myPicture As String
Because without it it's variant, myPicture = False (boolean) and the code goes down uncontrolled.
 
Upvote 0
Thank you both fro checking that out. I do have mypicture defined just as you have it.

I have found on several occasions Excel 2010 randomly crashes when running code with no rhyme or reason. This may just be another one of those examples.

Thanks again.
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top