Creating a Dynamic User form image without local files.

TheFlatTire

New Member
Joined
Mar 20, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have been trying to make an excel quiz application that will quiz my peers based on the images that appear. All runs smoothly, except I cannot get the images to change dynamically with in my user form. I do not want to have to reference local files (because many of them won't have them saved), so all of the images are stored on the quiz "master sheet". At the moment I have the image I wish to display running an index off of the question number in a separate work sheet. I pasted this indexed image which functions properly on the worksheet into my quiz user form. When operating the user form the image stays as the image that I pasted and won't change as the quiz advances unlike how it behaves on the worksheet. Is there a way to have the picture property of the image control refresh to the new image automatically?

I apologize if this makes no sense, I am very new to VBA. Thank you for any guidance.

______________________________________________________________
Sub get_quiz()
Call resetButton
Dim lRow As Integer
lRow = questionNo + 1

question = qSH.Range("A" & lRow).Value
Worksheets("Question Image").Range("A1").Value = question
' This pastes the name of the answer that the image indexes from for each question.

code = qSH.Range("B" & lRow).Value
choiceA = qSH.Range("C" & lRow).Value
choiceB = qSH.Range("D" & lRow).Value
choiceC = qSH.Range("E" & lRow).Value
choiceD = qSH.Range("F" & lRow).Value
answer = qSH.Range("G" & lRow).Value

txtQuestion.Value = question
txtSampleCode.Value = code
cmdA.Caption = choiceA
cmdB.Caption = choiceB
cmdC.Caption = choiceC
cmdD.Caption = choiceD



If questionNo = 20 Then
'Last question
cmdSubmit.Caption = "End Exam"
End If
End Sub
________________________________________________________________
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If you place your pictures on charts you can export the charts as png files. You could do this when your file first opens, saving the pics into the same folder as where they stored your file. You can then use the LoadPicture function to update the image control on the fly.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top