Individual Study Flex Project 2015-2016 Chris Ferguson (20.5 hours)

Learning the VBA Programming Language

The purpose of this project is to learn new technology, the VBA Programming Language. This is the programming environment for Microsoft Office (Word, Excel PowerPoint etc.). I concentrated on, and only worked with, using VBA with PowerPoint.

For an overview of the language here is the : Wikipedia entry

Here is how you get started:


I looked at dozens of YouTube videos dealing with VBA, here is by far the most helpful: VBA GAME Link (or view below)



An additional video that helps understand VBA objects: VBA OBJECTS Link (or view below)



An additional video that helps understand VBA slides: VBA SLIDES Link (or view below)

Here is where a professor or teacher might use VBA Programming. Below is a slide taken from one of my classes. The typical type of slide that is included with a text book. It is already quite 'busy' with a lot of information on the slide.

As an instructor, if I want to add to it, I must clutter it up MORE or add additional slides. With VBA programming you can add all sorts of extra information to a slide without displaying that information at all times.

FIRST, YOU MUST ADD SOME CODE TO YOUR SLIDE. Below is a screen shot of the 'Developer' tab. Do three things on this tab:
1 - Click on a control (like a label), 2 - Place the control on (or just off) the slide, 3 - Click on view code
Here is what the 'Developer Tab' should display:


We don't even care what we put on the slide at this point, we can change or delete it later. What we need is any code added to the page so we can write some VBA, here is what 'View Code' should display with MY highlighted line added:

NOW WE HAVE SOME CODE ADDED TO THE SLIDE. Running the slide show and clicking on the label should display:


If you want to be able to run code when ANYTHING is clicked (not just an Active-X control) you must save your PowerPoint as a 'Macro-Enabled Presentation'. This will allow clicking anything to run code:


With a 'Macro-Enabled Presentation' you can set a macro to run when just about any object is clicked. In this screen shot I add a subroutine to the run, I place an arrow on the screen, and go to the 'Insert'


Here is an example of what can be done with VBA programming. A teacher can build a slide and highlight the portions they are lecturing:

Once you know how to set up to do VBA programming, it is time to code. Below is examples of using variables, selection statements, arrays and other VBA code. This is NOT meant to be a complete example.


 
 ' Comment Example, Samples of VBA code

Private count As Integer                      ' declare global var
Private Const MAXCOUNT As Integer = 6         ' declare constant
Private Const SLIDE As String = "Slide3"      ' declare and init constant string
Private const MYDEBUG As Boolean = True       '  boolean

Private data                ' declare global array

'-----------------------------------------------------------------------------------

Sub test_me()
Dim name As String                 'declare local
data = Array(1, 2, 3, 4, 5, 6)     ' put info in arrays

If MYDEBUG = True Then
  MsgBox "Debug on"
End If



If count > 0 Then
  name = "Fred"
Else
  name = "Barney"
End If

Variable1.Caption = "New Value"   ' change text on screen  Variable1 MUST be active X lable

For i = 0 To count-1
  Variable1.Caption = "New Value" & data(i)   ' access array, update screen
Next i

End Sub