Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default INSERT PICTURE IN MACRO

oK i WANT TO RY THIS AGAIN. i AM A NOVICE SO PLEASE HELKP ME UNDERSTAND.
sorry...I do know how to record a macro but the help is needed to:

I want to build a macro that will allow a picture,clipart, to be inserted on
one worksheet if in another worksheet a cell ---let's say is true. How to do
this??? Does the clipart have to be on the page when recording the macro???
What is the programing to record??? Lets's say that :

In worksheet 1 that B3="3"
Macro would then insert the clipart in worksheet2 in a given spot because
B3 in worksheet one was equal to "3"

Hope I am making since:)
Glenn

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default INSERT PICTURE IN MACRO

My example uses the GetOpenFileName method to select the picture and includes
a Data Validation dropdown list to select a filter. To set this up:
1) On Sheet1 in cell D1 through D9 paste the following filter types:
..bmp
..emf
..gif
..jfif
..jpe
..jpg
..jpeg
..png
..wmf

2) Select cell A1 on Sheet1 and apply data validation to this cell:
i) Select Data from the main toolbar
ii) Select Validation...
iii) Select "List" from the "Allow:" dropdown list
iv) Ensure that the In-cell dropdown checkbox item is selected.
v) Click inside the "Source:" window and then select the range D1:D9 or
type in:
"=$D$1:$D$9".
vi) Clik OK
If the above has been done correctly, when you select cell A1, a dropdown
list should appear allowing you to select from the filter list in D1:D9.

3) In cell B1 enter the header "Top"
4) In cell C1 enter the header "Left"
5) In cell B2 enter a number(e.g. 4).
6) In cell C2 enter a number (e.g. 2).
7) Paste the following macro to a standard module.
8) Run the macro and select the desired picture. The picture will be pasted
to the top-left corner of cell B4 of Sheet2 if the above values in B2 and C2
are used. Note that the picture size keys off of the height of the
destination cell in Sheet2. These cells should be sized appropriately.

Sub InsertPict()
Dim txt As String
Dim PName As Variant
Dim P As Picture
Dim ws1 As Worksheet, ws2 As Worksheet
Dim R As Single
Dim rw As Long, col As Long
Dim c As Range

Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
txt = "*" & ws1.Range("A1").Value
rw = ws1.Range("B2").Value
col = ws1.Range("C2").Value
If Val(rw) = 0 Or Val(col) = 0 Then Exit Sub
Set c = ws2.Cells(rw, col)
With Application
PName = .GetOpenFilename("Picture files (" & txt & ")," & txt)
If PName = False Then Exit Sub
.ScreenUpdating = False
Set P = ws2.Pictures.Insert(PName)
R = P.Height / P.Width
P.Left = c.Left: P.Top = c.Top
P.Height = c.Height: P.Width = P.Height / R
.ScreenUpdating = True
End With
End Sub

Hope I didn't make a mistake in the post. I'm sick today and am having
trouble thinking clearly.

Regards,
Greg

"Glenn" wrote:

oK i WANT TO RY THIS AGAIN. i AM A NOVICE SO PLEASE HELKP ME UNDERSTAND.
sorry...I do know how to record a macro but the help is needed to:

I want to build a macro that will allow a picture,clipart, to be inserted on
one worksheet if in another worksheet a cell ---let's say is true. How to do
this??? Does the clipart have to be on the page when recording the macro???
What is the programing to record??? Lets's say that :

In worksheet 1 that B3="3"
Macro would then insert the clipart in worksheet2 in a given spot because
B3 in worksheet one was equal to "3"

Hope I am making since:)
Glenn

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
Insert Picture McCBeth Excel Worksheet Functions 2 March 17th 10 06:20 PM
Insert Picture from File - Shortcut/Macro? twinkle17 Excel Discussion (Misc queries) 2 November 26th 09 08:47 PM
Insert, position, and resize a picture w/ Macro John Excel Discussion (Misc queries) 1 July 10th 07 07:21 PM
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


All times are GMT +1. The time now is 03:14 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"