Friday, March 3, 2017

Set and get slide Activex controls properties from module

For PowerPoint VBA, there are two ways to control (access) ActiveX controls in certain slide from standard module.

Assume we want to get or set the value of toggle button, then we can do this using one of the following worked examples:

Example 1:

In module code, use the following code:

' Declare a public variable for toggle button value in module code
Public ToggleBtnValue As Boolean

' Sub-routine to call another sub-routine in slide 1
Sub SetToggleBtnValue()
Call Slide1.UpdateToggleBtn
End Sub

In slide 1 code, use the following code:

' In slide 1 code
Sub UpdateToggleBtn()     'Don't use "Private Sub"
MyToggleBtn.Value= ToggleBtnValue
End Sub

Example 2:

In module code, use the following code:

' Read toggle button value in slide number 1

' Set value of toggle button in slide number 1

The previous methods can be used to read or write any of the ActiveX control properties like back color, font name, font size, ... etc.

No comments:

Post a Comment