Tuesday, January 16, 2018

Jazz Presentation

Creating Jazz Presentations For Business


  • Theme Forest
  • PPT Guru

 Download This Article

In this Tutorial we will teach you on how to Write a Macro in PowerPoint Presentation, A Macro in a PowerPoint can help you to  automate frequently done tasks and do wonders.   A macro is a few line program which allows you to automate tasks and add functionality.  In this tutorial we will explain on what are the steps to Write a  Macro in Microsoft Point 2007 which will enable you to automate tasks in Microsoft PowerPoint 2007.
Macros is a set of  commands that are available in Visual Basic Application (VBA), and most people find it easier to build a macro than to write VBA code.

Step 1: Save the File with Correct Extension

As you get started the first step you should know is  how to save a PowerPoint file which contains a macro with correct file extension.  You need to ensure  you have saved the PowerPoint file you are working with macro enabled option.  Follow the image and the steps below.

  • Select the file save as option as shown in the  image below.
Write a Macro - Steps to Save with Correct File extn

Click on the image to see the full view

  • Save the PowerPoint with file Extension pptm (as shown in image below) and
  • file type PowerPoint Macro-Enabled Show (pptm) – (as shown in image below).
Write a Macro - Steps to SaveClick on the image to see the full view

Step 2 : Ensure Developer Tab is Enabled

Next step to Write a Macro will be to ensure Developer tab is enabled in menu ribbon.

1.    Select PowerPoint Options as shown in the image below.

Write a Macro - Enable Developer Tab
Click on the image to see the full view

2.    In the Options menu check the show developer Tab in the Ribbon as shown in the image below. This will enable the Developer Button in the Ribbon.

Write a Macro -Enable Developer Tab

Click on the image to see the full view

Step 3: Ensure PowerPoint is enabled to Write a Macro

You need to make sure the PowerPoint is enabled for macro writing. Do the following steps.

  • Click on the Ms office icon on the top left hand corner .and select the Option Menu
  • In the Option Menu Select Trust Center
  • Click on the Trust Center Setting and Select Macro Settings
  • Select the Radio button which has “Enable all macros” and Click on the ok. Button

This step will enable and allow you to run macro in the PowerPoint. The details are shown in the image below.

Write a Macro - Enable Macro

Click on the image to see the full view


Step 4: Name the Macro

Now we will give a name for a macro and write a macro, which you are planning to write.

1.    Open the Macro window from view menu as shown in the image below.

Write a Macro - Name the Macro

Click on the image to see the full view

2.    Name the macro

Click on the macro button in the view menu to open the macro window.  Give a name for the macro ( ex: Add_7Slides) to create a new macro called Add_7Slides.  Once you give the name for the macro the create button will get enabled as shown in the image.

Write a Macro - Name the Macro
Click on the Image to Enlarge

Step 5: Writing a Macro

Click on the create button, it will open up the Microsoft Visual Basic Macro Writing tool as in the image below.

Adding code to the macro

We will add the following line of code to the macro. The role of the macro is to add 7 blank slides to the PowerPoint file you are working on and display a Message box with a message Seven Slides have been added.   The Sample  Code is  shown below

'Sub is used for Declaring Functions in VB.
'Add_7Slides will be the Name of the Macro in our example

Sub Add_7Slides

'The For Loop is used to execute a piece of code multiple times
'In our Example we need to add 7 Slide so we would be executing it 7 Times

For I = 1 To 7

'This is the code which is actually going to add the slides.
'ActivePresentation.Slides.Add is a predefined function in VB which allows us to add slides to our Presentation
'ActivePresentation.Slides.Count is used to get the current count of the number of slides in the presentation
'We then increment it by 1 slide
'ppLayoutBlank is used to specify the style of the slid

ActivePresentation.Slides.Add (ActivePresentation.Slides.Count + 1), ppLayoutBlank
Next I

'The MsgBox is used to display a dialogue box to user with desired information

MsgBox ("Seven blank slides have been added.")
End Sub

The detail of how it appears in the Visual basic editor is shown in the image below

Write a Macro  - Write a code

Click on the image to Enlarge

Click on the save icon to save the code you have written, before it can be executed.

Step 6 : Run the Macro from Macro Menu

Now we will learn how to run the macro.  There are many ways to run the macro. In this step we will show how to run the macro from create macro window.

  • From the view menu, Click on the macro button
  • You can see the list of macros which have been created in the presentation so far.  Select the one which you would like to run (In our case Add_7Slides) and click on the run button.
  • As you click on the run button the macro will run and add 7 slides and will also display a message box 7 slides have been created.
  • The image below shows on how to click on the run the macro after you select the macro from the macro window.
Write a Macro - RunMacro

Click on the image to to see full view

Step 7 : Run the Macro from a Button in the Slide

1.  Create Button Object

  • Create a button Object in the slide.
  • From the Ribbon menu Bar, select the insert menu.
  • Then select a rectangle shape from the shape menu.
  • Create the Object in the Presentation
  • Give color and shape to the menu. ( In our example it is red button object we have created ( see image below)
Write a Macro - Run Macro 2

Click on the image to see full view

2.    Attach the Macro to the Button

  • Select the Button object.
  • Click on the Action button from the insert menu.
  • Select the run macro radio button.
  • Select the macro you want to attach (Add_7Slides).
  • Click on the Ok Button.
Write a Macro - Running Macro from Button Object

Click on the image to see full view

To run the Macro go to Slide show mode and click on the button object to which macro was attached.  The click will add 7 new slides.

We have done lot of research in Google and Amazon.com site and have given you below  few excellent books on how to Write a Macro with Visual basic Application for Microsoft.

1. Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive
2. Mastering VBA for Office 2010
3. Office VBA Macros You Can Use Today: Over 100 Amazing Ways to Automate Word, Excel, PowerPoint, Outlook, and Access
4. PowerPoint 2007: The Missing Manual

Hope this tutorial was helped you in learning how to Write a Macro in PowerPoint.

Rate this Post
Fatal error: Call to undefined function has_header_image() in /home3/solomon/public_html/wp-content/plugins/wp-postratings/wp-postratings.php on line 1189