#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Macro help

Hi, i need to modify this macro to insert a picture based on a value in cell
"A1"

Can this be done?
Thanks!


Sub Add_Picture()

'

'
Application.ScreenUpdating = False

'varible Picture1 is inserted down below - ***change both***
Picture1 =
Application.GetOpenFilename("Picture,*.JPG,Picture ,*.JPEG,Picture,*.GIF,Picture,*.BMP")
'edit "("Picture,*.*")" section to add or chanve visible file types

ActiveSheet.Pictures.Insert(Picture1).Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 175
Selection.ShapeRange.Width = 234
Application.ScreenUpdating = True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 703
Default Macro help

Not sure how to understand 'based on value', but if A1 holds the
filename like 'MyPicture.JPG' then this should do it:

Sub Add_Picture()
Application.ScreenUpdating = False

MyPath = "C:\Temp\" ' Change to suit
PictName = Range("A1").Value
Picture1 = MyPath & PictName
ActiveSheet.Pictures.Insert(Picture1).Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 175
Selection.ShapeRange.Width = 234

Application.ScreenUpdating = True
End Sub

Regards,
Per

On 16 Maj, 12:58, puiuluipui
wrote:
Hi, i need to modify this macro to insert a picture based on a value in cell
"A1"

Can this be done?
Thanks!

Sub Add_Picture()

'

'
* * Application.ScreenUpdating = False

* * 'varible Picture1 is inserted down below - ***change both***
* * Picture1 =
Application.GetOpenFilename("Picture,*.JPG,Picture ,*.JPEG,Picture,*.GIF,Pic*ture,*.BMP")
* * 'edit "("Picture,*.*")" section to add or chanve visible file types

* * ActiveSheet.Pictures.Insert(Picture1).Select
* * Selection.ShapeRange.LockAspectRatio = msoTrue
* * Selection.ShapeRange.Height = 175
* * Selection.ShapeRange.Width = 234
* * Application.ScreenUpdating = True

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Macro help

Thanks!

"Per Jessen" a scris:

Not sure how to understand 'based on value', but if A1 holds the
filename like 'MyPicture.JPG' then this should do it:

Sub Add_Picture()
Application.ScreenUpdating = False

MyPath = "C:\Temp\" ' Change to suit
PictName = Range("A1").Value
Picture1 = MyPath & PictName
ActiveSheet.Pictures.Insert(Picture1).Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 175
Selection.ShapeRange.Width = 234

Application.ScreenUpdating = True
End Sub

Regards,
Per

On 16 Maj, 12:58, puiuluipui
wrote:
Hi, i need to modify this macro to insert a picture based on a value in cell
"A1"

Can this be done?
Thanks!

Sub Add_Picture()

'

'
Application.ScreenUpdating = False

'varible Picture1 is inserted down below - ***change both***
Picture1 =
Application.GetOpenFilename("Picture,*.JPG,Picture ,*.JPEG,Picture,*.GIF,PicĀ*ture,*.BMP")
'edit "("Picture,*.*")" section to add or chanve visible file types

ActiveSheet.Pictures.Insert(Picture1).Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 175
Selection.ShapeRange.Width = 234
Application.ScreenUpdating = True

End Sub


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM


All times are GMT +1. The time now is 03:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"