Results 1 to 6 of 6
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in Powerpoint 2002(XP) the vba code is limited and not as extensive as Word or excel.

    Ive create a toolbar. on the toolbar Ive added a new button


    using code how do I add text on a button ie the label? ie TextOnly (Always)

    "Name:" isnt even a valid method?

    what are the powerpoint vba button properties?

    and how do I attach a macro to my new button

    ive the following code...


    With oButton
    .ToolTipText = "My tip here..."
    .OnAction = "my sub here"
    .Caption = ""New
    end With

    any ideas?

    diana
    Attached Images Attached Images

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Does this page help? http://msdn.microsoft.com/en-us/library/scff9c7c.aspx
    Code:
    ' Add a button to the command bar and create an event handler.
    		firstButton = CType(commandBar.Controls.Add(1), Office.CommandBarButton)
    		firstButton.Style = Office.MsoButtonStyle.msoButtonCaption
    		firstButton.Caption = "button 1"
    		firstButton.Tag = "button1"
    Shyam Pillai has a more readable example here http://www.tech-archive.net/pdf/Archive/Of...004-03/1935.pdf
    Code:
    With SubMenuItem
    .Caption = "Sub Menu Item"
    .Style = msoButtonCaption
    .OnAction = "MenuEvents" ' <− Macro to run when clicked.
    End With
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi Andrew

    yes thank you that helps
    the code is .NET. as i needed vba code i worked it out in vba

    to set the button properties i used the lines...

    With oButton
    .Style = msoButtonCaption
    .caption = "New"
    end With


    I was wondering how do I either:
    assign my code to the button or
    run my code from the button

    I have an addin with an Auto_Open sub

    my code looks like...

    With oButton
    .Style = msoButtonCaption
    .caption = "New"
    .Application.Run "'Auto_Open'!SetTemplate"
    end With


    diana

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ive worked it out

    to run assign code to a button...

    Sub Auto_open()
    With oButton
    .Style = msoButtonCaption
    .caption = "New"
    .Application.Run "SetTemplate"
    end With

    end Sub


    sub SetTemplate()
    'code here to call and set new template
    end sub

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    [quote name='Diana' post='786492' date='28-Jul-2009 13:19'].Application.Run "SetTemplate"[/quote]
    I was expecting the .OnAction to do the same thing but it is good that you have got it working now.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks Andrew

Posting Permissions

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