PDA

View Full Version : adding image to vba loaded userform sourced in sheet



mperrah
09-11-2007, 01:40 AM
I'm making a help file style userform.
A sheet (HelpSheet) has the contents used for the form.
One column has the labels and another the topics.
I want to add a picture (screen capture) for each topic (15 items)
The first column on the helpsheet is the label
second column the topic and the third column I have pasted the image.
On the userform I have added an image control (Image1)
Below is the code I am working on.
not sure how to embed the images.
Do I need to save the images in a directory (folder)
and have name and path stored in column 3 that the sub calls,
instead of the actual image in the column?
I'm very new to userforms...
Private Sub UpdateForm()
ComboBoxTopics.ListIndex = CurrentTopic - 1
Me.Caption = HelpFormCaption & _
" (" & CurrentTopic & " of " & TopicCount & ")"

With LabelText
.Caption = HelpSheet.cells(CurrentTopic, 2)
.AutoSize = False
.Width = 336
.AutoSize = True
End With
With Frame1
.ScrollHeight = LabelText.Height + 5
.ScrollTop = 1
End With
With Image1
.Picture = HelpSheet.cells(CurrentTopic, 3) 'need help here
End With

If CurrentTopic = 1 Then
NextButton.SetFocus
ElseIf CurrentTopic = TopicCount Then
PreviousButton.SetFocus
End If
PreviousButton.Enabled = CurrentTopic <> 1
NextButton.Enabled = CurrentTopic <> TopicCount
End Sub

Bob Phillips
09-11-2007, 02:00 AM
Take a look at http://www.oaltd.co.uk/Excel/Default.htm, PastePicture.zip

mperrah
09-11-2007, 12:38 PM
Thank you xld
I'll take a look tonight and test it out.
Mark

mperrah
09-11-2007, 09:24 PM
I have the label, topic and image on a sheet.
I have a sub that dynamicaly fills the userform.
Reading through other posts,
I realize that my content will not change very often
so having the userform dynamicaly load every time is not necessary
Is there a good source to learn how to populata a multipage userform
I have 15 pages of content.
I'll need the label to update for the page shown.
the buttons to update if on the first page no back option
on the last page no next option
and I have a drop down jump to list at the top to go directly to the page you want.
This all works dynamicaly now, but I'm not sure where to begin to make this all static..
any suggestions....
Or if there is an easy way to incorporate the image from the sheet the rest of the source data is located, that would be better - less changing.
I added a image control and named it, just need the code to update or insert the image as trhe shown page changes...
The image is located on a sheet in the same file, but can be moved to a folder if that works better.

any help is appreciated..
Mark

Bob Phillips
09-12-2007, 01:08 AM
Mark, what exactly do you mean by '... happens dynamically ... make static ...'? Can you post what you have and say what you want?

mperrah
09-12-2007, 05:26 PM
The file I have has screen captures inserted on a sheet (HelpSheet)
the size of the file even zipped is still 500k
By dynamic I mean, I click a menu I added to the tool bar labeled help,
and the userform pops-up, showing page one of a multipage form.
The sorce for the form resides on the sheet (Helpsheet)
the sheet has 15 rows of data and 3 columns
column one is the topic label, colun 2 is the topic data, column 3 is the screen capture image

the show form command fills the label and topic controls of the userform.
the topis label is a drop down list that will reload the page with the chosen topic.
I'm trying to fill the image control from the column 3 of the helpsheet.
My first post is the code that updates the form
it has a next and previous button and a close.

I call this dynamic because I did not build every page in the VBE.
Just made one page that has control that show different data based on the button clicks and drop down choice.

I could make each page seperatly in vbe and copy and paste all the data,
but since this could was loading everything, thought adding a picture from the same source sheet would be something vb could do...
just not sure how

I read your link and helps to add a picture from the clip board.
Maybe if the next button selects the image from the sheet and copies it to the clipboard then paste it to the form. This is beyond my code skills.

If there is no method in vba to select an image placed on a sheet
to be inserted in the image control of a userform
then I will try hand coding each page...