I have a table on slide 2 of my PowerPoint presentation with three values: 100, 120, and 300. I have hyperlinked these values to slides 4, 5, and 6, respectively.
I want to write a VBA code that returns the value from slide 2 (100, 120, or 300) based on which slide I'm on during the presentation. Basically I want to find the number that lives on slide 2 that I hyperlinked to the current slide I'm on.
For example, if I'm presenting slide 4, the code should return 100, if I'm on slide 5, it should return 120, and if I'm on slide 6, it should return 300. How can I implement this in VBA?
I found the answer to my question
Sub CheckSlideNumberHyperlink()
Dim slide As slide
Dim hyperlink As hyperlink
Dim current_slide_index As Integer
Dim slide_index As Integer
' Set the slide you want to check
Set slide = ActivePresentation.Slides(2)
' Get current slide number
Set current_slide = ActivePresentation.SlideShowWindow.View.slide
current_slide_index = current_slide.slideIndex
' Loop through all hyperlinks on the slide
For Each hyperlink In slide.Hyperlinks
' Check if the hyperlink is associated with the slide number
If IsSlideNumberHyperlink(hyperlink) Then
' Get the target slide number
targetSlideNumber = hyperlink.SubAddress
problem_value = hyperlink.TextToDisplay
parts = Split(targetSlideNumber, ",")
slide_index = parts(1)
If current_slide_index = slide_index Then
MsgBox problem_value
End If
End If
Next hyperlink
End Sub