excel-vba Getting started with excel-vba Adding a new Object Library Reference


Example

The procedure describes how to add an Object library reference, and afterwards how to declare new variables with reference to the new library class objects.

The example below shows how to add the PowerPoint library to the existing VB Project. As can be seen, currently the PowerPoint Object library is not available.

enter image description here

Step 1: Select Menu Tools --> References… enter image description here

Step 2: Select the Reference you want to add. This example we scroll down to find “Microsoft PowerPoint 14.0 Object Library”, and then press “OK”. enter image description here

Note: PowerPoint 14.0 means that Office 2010 version is installed on the PC.

Step 3: in the VB Editor, once you press Ctrl+Space together, you get the autocomplete option of PowerPoint. enter image description here

After selecting PowerPoint and pressing ., another menu appears with all objects options related to the PowerPoint Object Library. This example shows how to select the PowerPoint's object Application. enter image description here

Step 4: Now the user can declare more variables using the PowerPoint object library.

Declare a variable that is referencing the Presentation object of the PowerPoint object library. enter image description here

Declare another variable that is referencing the Slide object of the PowerPoint object library. enter image description here

Now the variables declaration section looks like in the screen-shot below, and the user can start using these variables in his code. enter image description here

Code version of this tutorial:

Option Explicit

Sub Export_toPPT()

Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide

' here write down everything you want to do with the PowerPoint Class and objects


End Sub