Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Links / July 2005

Tip: Looking for answers? Try searching our database.

linking photos

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Smitty - 28 Jul 2005 16:24 GMT
Oddly enough I was going to just post a question about bringing in a new
picture depending on what doc I was in, and lo-n-behold, the answer may be
very similar to Joe Williams.  

I'll make this very generic.  :-)   I have one multi-sheet Excel file with a
picture on the top of each page.  We'll say each report is about one cow.  
This report will be duped with new numbers for 20 different cows.  Now I
would like the picture of the cow on the top of each page to change depending
on what cow we're reporting on.  So if report #1 is about cow #1, I want to
be able to tell the report to update each picture to that of cow #1.  After
it updates, it needs to break any links that it established (don't know if it
would, but I can't send it to the client with it trying to update anything).  
Then I move on to report #2 about cow #2, and it updates to the picture of
cow #2.  

Does that make sense?  If not let me know and I'll try it again.  Thanks
very much!!

Excel 2002
Ed Ferrero - 28 Jul 2005 23:50 GMT
HI Smitty,

You can use the method described in my earlier reply to Joe William.

Assume that 'cow#1', 'cow#2' etc are in cell A1 of each sheet.
Assume cell A2 contains the path for each picture.

This code will create a blank chart on each sheet in a workbook, and
import a picture into the chart based on the contents of cell A1 and A2.

The pictures are not linked, so it is safe to send the resulting workbook
to a client.

The code has been modified slightly to make it more generic. You need
to run the macro 'SetPicsForAllSheets' once to set the pictures for
all worksheets.

Sub SetPicsForAllSheets()
Dim sh As Worksheet
Dim strPic As String
Dim strPth As String
Dim strExt As String

For Each sh In ActiveWorkbook.Worksheets
 strPic = sh.Range("A1")   ' name of picture to import e.g. cow#1
 strPth = sh.Range("A2")   ' path of picture e.g. C:\My Documents\
 strExt = sh.Range("A3")   ' file extension for picture e.g. .jpg, .gif

 Call BuildChartPic(sh.Name, strPic, strPth, strExt)
Next sh
End Sub

Sub BuildChartPic(strSht As String, strPic As String, strPth As String,
strExt As String)
Dim ch As ChartObject
' build full path and file name
strPic = strPth & strPic & strExt

Set ch = Worksheets(strSht).ChartObjects.Add(100, 30, 400, 250)

ch.Activate
ActiveChart.ChartArea.Fill.UserPicture PictureFile:=strPic

End Sub

Ed Ferrero
http://edferrero.m6.net

> Oddly enough I was going to just post a question about bringing in a new
> picture depending on what doc I was in, and lo-n-behold, the answer may be
[quoted text clipped - 21 lines]
>
> Excel 2002
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.