ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple macro to insert user selected picture into Excel 2003 (https://www.excelbanter.com/excel-programming/423883-simple-macro-insert-user-selected-picture-into-excel-2003-a.html)

Melody

Simple macro to insert user selected picture into Excel 2003
 
Hi,

I currently have a protected spreadsheet that I want to add pictures too. I
have been able to figure out a certain amount of the programming but I'm not
aware of how to make it open a browser window to pick the file rather than
insert a specific file. Let me emphasize, I want to keep this simple. Below
is what I have so far. What do I replace the specific file pick with to
allow for any picture file to be picked?

ActiveSheet.Unprotect
Range("A1:B2").Select

' This is the part I need to change.
ActiveSheet.Pictures.Insert( _
"C:\Documents and
Settings\casem02.AMER\Desktop\32604galloapproval.j pg").Select

Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 712#
Selection.ShapeRange.Width = 892#
Selection.ShapeRange.Rotation = 0#
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowInsertingRows:=True
End Sub


Gary''s Student

Simple macro to insert user selected picture into Excel 2003
 
Use a dialog box:

Sub dural()
myPictureName = Application.GetOpenFilename _
(filefilter:="Picture Files,*.jpg;*.bmp;*.tif;*.gif")
ActiveSheet.Pictures.Insert(myPictureName).Select

End Sub

--
Gary''s Student - gsnu200832


"Melody" wrote:

Hi,

I currently have a protected spreadsheet that I want to add pictures too. I
have been able to figure out a certain amount of the programming but I'm not
aware of how to make it open a browser window to pick the file rather than
insert a specific file. Let me emphasize, I want to keep this simple. Below
is what I have so far. What do I replace the specific file pick with to
allow for any picture file to be picked?

ActiveSheet.Unprotect
Range("A1:B2").Select

' This is the part I need to change.
ActiveSheet.Pictures.Insert( _
"C:\Documents and
Settings\casem02.AMER\Desktop\32604galloapproval.j pg").Select

Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 712#
Selection.ShapeRange.Width = 892#
Selection.ShapeRange.Rotation = 0#
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowInsertingRows:=True
End Sub


Melody

Simple macro to insert user selected picture into Excel 2003
 
Worked great. Nice and Simple. Thanks.

"Gary''s Student" wrote:

Use a dialog box:

Sub dural()
myPictureName = Application.GetOpenFilename _
(filefilter:="Picture Files,*.jpg;*.bmp;*.tif;*.gif")
ActiveSheet.Pictures.Insert(myPictureName).Select

End Sub

--
Gary''s Student - gsnu200832


"Melody" wrote:

Hi,

I currently have a protected spreadsheet that I want to add pictures too. I
have been able to figure out a certain amount of the programming but I'm not
aware of how to make it open a browser window to pick the file rather than
insert a specific file. Let me emphasize, I want to keep this simple. Below
is what I have so far. What do I replace the specific file pick with to
allow for any picture file to be picked?

ActiveSheet.Unprotect
Range("A1:B2").Select

' This is the part I need to change.
ActiveSheet.Pictures.Insert( _
"C:\Documents and
Settings\casem02.AMER\Desktop\32604galloapproval.j pg").Select

Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 712#
Selection.ShapeRange.Width = 892#
Selection.ShapeRange.Rotation = 0#
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowInsertingRows:=True
End Sub



All times are GMT +1. The time now is 01:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com