FracinDean
Board Regular
- Joined
- Jul 11, 2011
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
Mr. Excel Forum Members,
I am trying to do something similar to what was described in another thread on this forum, Show worksheet range of cells in a User Form. In my case, I'm trying to copy a named range in my workbook and paste it as a picture into a user form. As far as I can figure out, there are 5 things I must do to get this to work
1) Add a Class module with the code mentioned in the linked thread. Done.
2) Add a user form. I added a user form called "myLegend".
3) Write a sub to copy the desired image to the clipboard. Step 3 has been coded and tested by running the sub below and then manually pasting the image, but here is the code for information:
4) Add a procedure to initialize the form:
5) Add the code to the UserForm module to execute whenever the form is initialized.
When I run the procedure loadLegend(), I'm getting a compile error on the "With Me.Legend1" statement in the Userform_Initialize procedure, The error message says "Method or data member not found."
I don't know how to fix this error. Any assistance would be appreciated.
I am trying to do something similar to what was described in another thread on this forum, Show worksheet range of cells in a User Form. In my case, I'm trying to copy a named range in my workbook and paste it as a picture into a user form. As far as I can figure out, there are 5 things I must do to get this to work
1) Add a Class module with the code mentioned in the linked thread. Done.
2) Add a user form. I added a user form called "myLegend".
3) Write a sub to copy the desired image to the clipboard. Step 3 has been coded and tested by running the sub below and then manually pasting the image, but here is the code for information:
VBA Code:
Sub CopyImageToCBoard()
Application.CutCopyMode = False
With Worksheets("Steward Data")
Range("theLegend").CopyPicture Appearance:=xlScreen, Format:=xlPicture
End With
End Sub
4) Add a procedure to initialize the form:
VBA Code:
Sub loadLegend()
Load myLegend
End Sub
5) Add the code to the UserForm module to execute whenever the form is initialized.
VBA Code:
Private Sub UserForm_Initialize() 'goes in the UserForm code module for form 'myLegend'
Application.ScreenUpdating = False 'Turn off screen updating
Call CopyImageToCBoard 'sub that copies the desired range to the clipboard
With Me.Image1
.Picture = LoadPicture(vbNullString) ' clear existing picture
.Picture = PastePicture(xlPicture) ' paste range of info copied
End With
Application.ScreenUpdating = True 'Turn on screen updating
myLegend.Show
End Sub
When I run the procedure loadLegend(), I'm getting a compile error on the "With Me.Legend1" statement in the Userform_Initialize procedure, The error message says "Method or data member not found."
I don't know how to fix this error. Any assistance would be appreciated.