B
brownti via OfficeKB.com
I am using the following code and it works, but i would like to make a couple
changes to it that i am not sure how to do. The first thing is that i plan
on using the same code for numerous different ranges. so i was thinking that
i would have 5 different buttons on my sheet and when i click the first
button it would set the range to be used, set the picture to be used and then
run the below macro using the variables that the first macro set. For
example:
Sub pictureone()
Dim myPictureName As Variant
Dim myRng As Range
myPictureName = "I:\Shop drawings\Doors\Raised panel\belmont.jpg"
With ActiveSheet
Set myRng = .Range("e16:f20")
End With
If myPictureName = False Then
Exit Sub 'user hit cancel
End If
Call pictureinsert
End Sub
Public Sub pictureinsert()
Dim myPict As Picture
With ActiveSheet
Set myPict = .Pictures.Insert(myPictureName)
myPict.top = myRng.top
myPict.Width = myRng.Width
myPict.Height = myRng.Height
myPict.Left = myRng.Left
myPict.Placement = xlMoveAndSize
End With
End Sub
Any thoughts on how i can make this work would be appreciated. Thanks
changes to it that i am not sure how to do. The first thing is that i plan
on using the same code for numerous different ranges. so i was thinking that
i would have 5 different buttons on my sheet and when i click the first
button it would set the range to be used, set the picture to be used and then
run the below macro using the variables that the first macro set. For
example:
Sub pictureone()
Dim myPictureName As Variant
Dim myRng As Range
myPictureName = "I:\Shop drawings\Doors\Raised panel\belmont.jpg"
With ActiveSheet
Set myRng = .Range("e16:f20")
End With
If myPictureName = False Then
Exit Sub 'user hit cancel
End If
Call pictureinsert
End Sub
Public Sub pictureinsert()
Dim myPict As Picture
With ActiveSheet
Set myPict = .Pictures.Insert(myPictureName)
myPict.top = myRng.top
myPict.Width = myRng.Width
myPict.Height = myRng.Height
myPict.Left = myRng.Left
myPict.Placement = xlMoveAndSize
End With
End Sub
Any thoughts on how i can make this work would be appreciated. Thanks