vbavariablespowerpointusing

How to use variable value declared in Microsoft PowerPoint Object module in Main Module


I need to refer the variables in slide object modules to refresh the charts which I am struggling since a week. Could anyone help me please?

I just need make Slide2146449163 as variable since SRngMkt, SRngClt etc are defined in Slide2146449163. I have similar slides for other markets and countries

Public Sub test()

Set ActSld = ActiveWindow.View.Slide
Debug.Print ActSld.Name
SldNum = ActSld.SlideID
'SldNum = ActiveWindow.View.Slide.SlideIndex
Debug.Print SldNum

Debug.Print ActSld.Name, ActSld.SlideID, ActSld.SlideNumber, ActSld.SlideIndex

Debug.Print ActSld.SRngMkt <--- ActSld should be dynamic. Giving error
Debug.Print Slide2146449163.SRngClt <--- works perfectly fine
Debug.Print Slide2146449163.SRngHub
Debug.Print Slide2146449163.SRngCTSS

End Sub

Below is the code written in slide object module

Public Sub cmd_Ink_CEE_Germany_Click()

SRngMkt = "CENTRAL & EASTERN EUROPE"
SRngClt = "*"
SRngHub = "Germany"
SRngCTSS = "Included"

Call test

End Sub

enter image description here


Solution

  • Public Sub Refresh_Charts(SRngCTSS As String, SRngClt As String,  SRngHub As String,  SRngCTSS As String)
    '...'
    xlWS.Range("E4").Value = SRngMkt <------- This line is working but Slide2146449163 should be dynamic
    xlWS.Range("J4").Value = SRngClt
    xlWS.Range("O4").Value = SRngHub
    xlWS.Range("T4").Value = SRngCTSS
    '...'
    End Sub
    
    
    Public Sub cmd_Ink_CEE_Germany_Click()
        ' Use local variables
        Dim SRngCTSS As String, SRngClt As String, SRngHub As String, SRngCTSS As String
        SRngMkt = "CENTRAL & EASTERN EUROPE"
        SRngClt = "*"
        SRngHub = "Germany"
        SRngCTSS = "Included"
        ' pass arguments to Refresh_Charts
        Call Refresh_Charts(SRngCTSS, SRngClt,  SRngHub,  SRngCTSS)
    
    End Sub