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
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
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"
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