-
Dec 6th, 2022, 08:50 AM
#1
Thread Starter
New Member
Powerpoint Image control
Hi!
I am VERY new to VBA and coding.
I am trying to create a bingo game in powerpoint for work. However I want the bingo caller to display images. Currently, I have label controls that display each picture and it randomizes based on a command button. However, I would like to have an Image control on the side that displays the picture from the label control that is being called at that moment and then switch when the next one is called, etc. I have not been able to figure out how to do this. I can have the pictures to pull from on a separate slide but I am not sure how to create the path to them in code or do something that would be easier.
This is my code so far (plus a currently empty image control):
Code:
Dim arr(26)
Dim rndCount As Integer
Dim number As Integer
Private Sub CommandButton1_Click()
Display.Caption = ""
Erase arr()
Display.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = False
Label9.Visible = False
Label10.Visible = False
Label11.Visible = False
Label12.Visible = False
Label13.Visible = False
Label14.Visible = False
Label15.Visible = False
Label16.Visible = False
Label17.Visible = False
Label18.Visible = False
Label19.Visible = False
Label20.Visible = False
Label21.Visible = False
Label22.Visible = False
Label23.Visible = False
Label24.Visible = False
Label25.Visible = False
End Sub
Private Sub CommandButton2_Click()
Randomize
Display.Visible = True
Do While rndCount <= 10000
number = Int((25 * Rnd) + 1)
rndCount = rndCount + 1
If arr(number) <> number Then
arr(number) = number
Display.Caption = number
Exit Do
End If
Loop
If Display.Caption = 1 Then
Label1.Visible = True
ElseIf Display.Caption = 2 Then
Label2.Visible = True
ElseIf Display.Caption = 3 Then
Label3.Visible = True
ElseIf Display.Caption = 4 Then
Label4.Visible = True
ElseIf Display.Caption = 5 Then
Label5.Visible = True
ElseIf Display.Caption = 6 Then
Label6.Visible = True
ElseIf Display.Caption = 7 Then
Label7.Visible = True
ElseIf Display.Caption = 8 Then
Label8.Visible = True
ElseIf Display.Caption = 9 Then
Label9.Visible = True
ElseIf Display.Caption = 10 Then
Label10.Visible = True
ElseIf Display.Caption = 11 Then
Label11.Visible = True
ElseIf Display.Caption = 12 Then
Label12.Visible = True
ElseIf Display.Caption = 13 Then
Label13.Visible = True
ElseIf Display.Caption = 14 Then
Label14.Visible = True
ElseIf Display.Caption = 15 Then
Label15.Visible = True
ElseIf Display.Caption = 16 Then
Label16.Visible = True
ElseIf Display.Caption = 17 Then
Label17.Visible = True
ElseIf Display.Caption = 18 Then
Label18.Visible = True
ElseIf Display.Caption = 19 Then
Label19.Visible = True
ElseIf Display.Caption = 20 Then
Label20.Visible = True
ElseIf Display.Caption = 21 Then
Label21.Visible = True
ElseIf Display.Caption = 22 Then
Label22.Visible = True
ElseIf Display.Caption = 23 Then
Label23.Visible = True
ElseIf Display.Caption = 24 Then
Label24.Visible = True
ElseIf Display.Caption = 25 Then
Label25.Visible = True
End If
End Sub
-
Dec 6th, 2022, 11:50 AM
#2
Re: Powerpoint Image control
-
Dec 8th, 2022, 05:55 PM
#3
Member
Re: Powerpoint Image control
Hi. My apologies, but I don't properly understand what it is that you're trying to do. Your reference to Labels, CommandButtons and Image controls suggests to me that you're dealing primarily with a userform, but then your reference slides would suggest otherwise (in which case, I'm not entirely sure why you're using label controls at all).
If it's the former, then a picture loaded into one control are simple stdPicture objects, in which case they can be easily passed from one to the other.
Code:
Image1.Picture = Label1.Picture
and so on. If the latter, then I wonder if perhaps there is a better way of loading images than the copy/paste method.
Could you possibly post an image of what you're attempting to do?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|