06-29-2010, 10:16 PM
I would like your help in showing me how to add a picture to the form which the picture not link to external source like in c drive but instead the picture i save inside the excel worksheet, same file with the form.
Appreciated your reply,
06-30-2010, 07:30 AM
You are likely to need to tweak this to get the exact size metrics right, but something along the lines of:
Public Sub PicFromWsToForm()
Dim cht As ChartObject, shp As Shape
Dim strPic As String
strPic = "C:\TempImage.gif"
Set shp = Sheet1.Shapes(1) 'assumes 1st shape in sheet is desired picture
'paste the pic into a chart and then export chart as image file
With Sheet1.ChartObjects.Add(1, 1, shp.Width, shp.Height)
.Border.LineStyle = 0
.Interior.ColorIndex = xlNone
'insert pic into form
.Picture = LoadPicture(Filename:=strPic)
.Width = shp.Width
.Height = shp.Height
Kill PathName:=strPic 'delete the image from disk
06-30-2010, 09:16 PM
Thank you for your reply Jonvdheyden,
Is there any way you can help upload a working sample for the above method?
I can study it from there.
07-01-2010, 01:23 AM
I've attached XL03 xls file as an example.
07-02-2010, 12:31 AM
Thank you for that. However what i try to do is when i open up the form, the form automatically show the picture without clicking. the form in the other hand were link to the toolbar.
You know how to do so?
07-02-2010, 01:26 AM
I don't understand. How exactly do you want this to work?
07-02-2010, 03:11 AM
Here what i want to do.
I create a userform and all it code and function into file A(for example)
Then i link up the userform with the toolbar using macro as per step 1 picture.
When i click on one of the form, the form will show up like in the step 2.
The form that come out with the picture on it.
The picture then is set to taken from the sheet(either hidden or not).
That i looking for.
Can you help?