B
brownti via OfficeKB.com
I am trying to select a variable in one sub procedure and then use that
variable in another procedure. I am using the following code:
Dim paneltype As String
Sub CommandButton1_Click()
Dim myPict As Picture
Dim myRng As Range
With ActiveSheet
Set myRng = .Range("i16:m28")
Set myPict = .Pictures.Insert(paneltype)
myPict.top = myRng.top
myPict.Width = myRng.Width
myPict.Height = myRng.Height
myPict.Left = myRng.Left
myPict.Placement = xlMoveAndSize
End With
End Sub
Sub CommandButton2_Click()
Dim paneltype As Variant
paneltype = Application.GetOpenFilename
If paneltype = False Then
Exit Sub 'user hit cancel
End If
panelimage.Picture = StdFunctions.LoadPicture(paneltype)
End Sub
When i click commandbutton2 it selects the picture and then when i click
commanbutton1 it is supposed to insert the picture, although it has trouble.
Any ideas?
variable in another procedure. I am using the following code:
Dim paneltype As String
Sub CommandButton1_Click()
Dim myPict As Picture
Dim myRng As Range
With ActiveSheet
Set myRng = .Range("i16:m28")
Set myPict = .Pictures.Insert(paneltype)
myPict.top = myRng.top
myPict.Width = myRng.Width
myPict.Height = myRng.Height
myPict.Left = myRng.Left
myPict.Placement = xlMoveAndSize
End With
End Sub
Sub CommandButton2_Click()
Dim paneltype As Variant
paneltype = Application.GetOpenFilename
If paneltype = False Then
Exit Sub 'user hit cancel
End If
panelimage.Picture = StdFunctions.LoadPicture(paneltype)
End Sub
When i click commandbutton2 it selects the picture and then when i click
commanbutton1 it is supposed to insert the picture, although it has trouble.
Any ideas?