Insert Picture,compression, compile error. easy one for you

micksid

New Member
Joined
Jun 7, 2011
Messages
11
hello

i have created a button on a excel sheet to open up a dialog box to insert a picture that the user selects. it worked fine on my personal laptop but when i put it on my work laptop i get compile error, cant find project or libary.....the error highlights the "picture1" section below

what im basically wanting the macro to do is

  • open dialog for user to select jpg file from anywhere on there computer
  • insert the selected picture onto the worksheet
  • resize to a specific size
  • compress the picture down to "web 96DPI"
just to add to the above, there is also company logo that is on top of the sheet, which i want to be there all the time


code is below

Sub Add_Picture()
'
Application.ScreenUpdating = False
ActiveSheet.Unprotect ("******")
On Error Resume Next

Picture1 = Application.GetOpenFilename("Picture,*.JPG,Picture,*.JPEG,Picture,*.GIF,Picture,*.BMP")


Range("c66").Select
ActiveSheet.Pictures.Insert(Picture1).Select

Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 175
Selection.ShapeRange.Width = 234
'Selection.ShapeRange.ScaleWidth 1.5, msoFalse, msoScaleFromTopLeft
'Selection.ShapeRange.ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft
'Selection.ShapeRange.IncrementLeft 50
'Selection.ShapeRange.IncrementTop 4

Application.ScreenUpdating = False

'''''''''' Below is to compress the images ''''''''''''

Dim octl As CommandBarControl
With Selection
Set octl = Application.CommandBars.FindControl(ID:=6382)
Application.SendKeys "%e~"
Application.SendKeys "%a~"
Application.SendKeys "%w~"
octl.Execute
End With
End Sub


PLEASE PLEASE PLEASE HELP. i dont mind using another method/macro to insert a picture.

cheers
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,215,327
Messages
6,124,289
Members
449,149
Latest member
mwdbActuary

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