Results 1 to 2 of 2

Thread: Macros for Powerpoint

  1. #1

    Thread Starter
    Lively Member magoochris's Avatar
    Join Date
    Nov 2001
    Location
    Australia
    Posts
    81

    Question Macros for Powerpoint

    I am trying to use macros for powerpoint, things I am trying to do include:
    Copying selected slides from one presentation to another
    importing a presentation into the current one
    and other jusnk like that.
    can anyone help me?

  2. #2
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Some pointers that MIGHT help...

    A new command button can be added into PowerPoint.
    VB Code:
    1. Sub Add_RegFile_Button()
    2. ' First delete the added buttons
    3. Set Buttons = CommandBars("Standard").Controls
    4. For Each Control In Buttons
    5.     If (Control.BuiltIn = False) _
    6.         And Control.Caption = "Your Button Text" Then
    7.         Control.Delete
    8.     End If
    9. Next Control
    10.  
    11. Set newItem = _
    12.      CommandBars("Standard").Controls.Add(Type:=msoControlButton)
    13. With newItem
    14.     .BeginGroup = True
    15.     .Caption = "Your Button Text"
    16.     .FaceId = 455
    17.     .OnAction = "YourProgName"
    18. End With
    19. End Sub
    This macro is in two parts – the first part deletes any button with the same name that you are about to add. This “delete first” allows you to run the macro as often as you like, without new buttons being added each time.

    The second part adds the new button in to the “Standard” command bar.
    · The .OnAction calls another sub routine VBA macro.
    · The .Caption is what the user sees when they hover the mouse over the button.
    · The .FaceID is the number of an icon to appear on the button. Getting your own icon on the button might be possible, but it does not seem to be documented as to how to do it!
    See the MS Office 2000 Visual Basic Programmers Guide for more details.


    In order for PowerPoint to call an external application, a VBA macro needs to be written. Typically the name of the subroutine of this macro is the one specified in the .OnAction described above.
    VB Code:
    1. Sub YourSub()
    2.     TempDoc = Environ("Temp") & "\Presentation.PPT"
    3.     ActivePresentation.SaveCopyAs TempDoc
    4.  
    5.     RegFiler = GetSetting("YourRegistry", "Startup", "Location", "")
    6.  
    7.     AppName = RegFiler & " " & Chr(34) & TempDoc & Chr(34)
    8.     rc = Shell(AppName, vbNormalFocus)
    9. End Sub
    This macro performs three actions:
    · Save a copy of the current work book to a temporary location and temporary name. The location of the Temp folder is found from the Environment variables on the PC.
    · Identify the name of the application to be launched from the Registry using the GetSetting command.
    · Launch the required application, using the name of the saved document as a parameter enclosed in “” (the Chr(34) is a double quote mark).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width