Setting Global Variables in VBA

Posted by dennis96411 on Stack Overflow See other posts from Stack Overflow or by dennis96411
Published on 2012-09-03T01:52:10Z Indexed on 2012/09/03 3:38 UTC
Read the original article Hit count: 190

Filed under:
|
|
|
|

I'm currently making an "OS" in PowerPoint and I need to know how to set global variables for the settings.

I made a module called "Settings" containing:

Public Sub Settings()

Option Explicit
Public UserName, UserIcon, Background, BrowserHomePage As String
Public SetupComplete As Boolean

SetupComplete = False
UserName = "Administrator"
UserIcon = Nothing
Background = Nothing
BrowserHomePage = Nothing

'Set the variables
UserName.Text = UserName

End Sub

Now on the "log in" screen, I have a text box named "UserName". I then made a button just to test out the variables. The button does this:

Private Sub CommandButton1_Click()
UserName.Value = UserName
End Sub

The text box has no value when I click the button. I'm super new at VBA, and would like to know how to do this. Also, if anyone knows how to automatically execute codes when starting the PowerPoint, that would be fantastic.

© Stack Overflow or respective owner

Related posts about vba

Related posts about variables