Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dynamically insert a picture.

I would like to take a cell value and use it to dynamically enter in a
picture (really a Visio diagram).

For Example:
- If the cell A2s value was €œA423€
- It would look for the Visio diagram that corresponds to its name under
some folder structure like, €œ/some_folder/A423.vsd€
- Then insert that image/diagram into the Excel worksheet at a particular
area.

Does anyone have any ideas on doing this dynamically, if worse case would
like to have one macro that would insert multiple images, per each page in a
worksheet?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Dynamically insert a picture.

Here is code that will detect a change in cell A2 of any worksheet, will look
for the existence of the specified file, and will insert the picture on the
worksheet - put the path to the folder containing your pictures into
FolderPath and replace ".jpg" as needed:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim TestRange As Range, FolderPath as String, PicFilePath As String
FolderPath = "C:\FolderName\SubFolderName\"
Set TestRange = Intersect(Sh.Range("A2"), Target)
If Not TestRange Is Nothing Then
PicFilePath = Folderpath & Sh.Range("A2").Value & ".jpg" ' REPLACE .jpg
IF NEEDED
If Dir(PicFilePath) = "" Then
MsgBox "File " & PicFilePath & " could not be found", vbExclamation,
"CANNOT INSERT PICTU"
Else
Sh.Range("B2").Select
Sh.Pictures.Insert PicFilePath
End If
End If
End Sub

(Written in Excel XP, cannot say if it works for earlier versions)
HTH! K Dales

"Cherokee84" wrote:

I would like to take a cell value and use it to dynamically enter in a
picture (really a Visio diagram).

For Example:
- If the cell A2s value was €œA423€
- It would look for the Visio diagram that corresponds to its name under
some folder structure like, €œ/some_folder/A423.vsd€
- Then insert that image/diagram into the Excel worksheet at a particular
area.

Does anyone have any ideas on doing this dynamically, if worse case would
like to have one macro that would insert multiple images, per each page in a
worksheet?

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
how do I insert picture into cell so vlookup can return picture? ah Excel Worksheet Functions 1 May 1st 07 04:38 AM
insert a picture in to a comment but picture not save on hard disk Pablo Excel Discussion (Misc queries) 0 February 21st 07 03:48 PM
Insert a specified number of rows dynamically ttbbgg Excel Worksheet Functions 2 March 20th 06 08:27 PM
insert picture chad Excel Programming 1 May 13th 04 01:35 AM
can i insert a picture Henrik Wendel Excel Programming 0 July 14th 03 07:51 PM


All times are GMT +1. The time now is 07:09 AM.

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

About Us

"It's about Microsoft Excel"