Consulting

Results 1 to 17 of 17

Thread: Something wrong in XML? Or in VBA? Or something missing anywhere?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Contributor
    Joined
    Apr 2015
    Location
    Germany
    Posts
    167
    Location

    Something wrong in XML? Or in VBA? Or something missing anywhere?

    Hi there,

    I'm a big fan of toggle buttons :-)

    Well, in fact, I try to create one by myself for the first time. I read the tutorial of Gregory K. Maxey and tried to do it by myself in XML and PPTX 2010 for a TextBox appearing/getting deleted from the slidemaster. XML validation says: Well formed. VBA debugging doesn't say anything. But pressing my button says: Macro not found. I have no idea what went wrong and would appreciate your help very much.

    Thanks,
    RG

    This is what I wrote in XML:

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon startFromScratch="false">
    <tabs>
    <tab id="RGHomeTab" label="RG Home">
    <group id="ToggleTest" label="Test">
    <toggleButton id="customButton7" image="PH" onAction="RibbonControl.ToggleonAction" getPressed="RibbonControl.buttonPressed"/>
    </group>
    </tab>
    </Tabs>
    </ribbon>
    </customUI>
    My VBA code is:
    Sub ToggleonAction(control As IRibbonControl, pressed As Boolean)
      Select Case control.Id
        Case Is = "customButton7"
    
          If pressed Then
        Dim shp As Shape
    
        Set shp = Application.ActivePresentation.SlideMaster.Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=39.118086, Top:=5.6692878, Width:=26.362188, Height:=21.826758)
    With shp
        .Fill.Visible = msoFalse
        .Line.Visible = msoFalse
        .Name = "Draftmaster"
        
    With .TextFrame
        .TextRange.Text = "Draft"
        .VerticalAnchor = msoAnchorTop
        .MarginBottom = "3,685037"
        .MarginLeft = "0"
        .MarginRight = "0"
        .MarginTop = "3,685037"
        .WordWrap = msoFalse
        
    With .TextRange
        .Font.Size = 12
        .Font.Name = "Arial"
        .Font.Color.RGB = RGB(89, 171, 244)
        .ParagraphFormat.Alignment = ppAlignLeft
    End With
    End With
    End With
    
          Else
            Application.ActivePresentation.SlideMaster.Shapes(Draftmaster) = Delete
          End If
      End Select
    End Sub

    Sub buttonPressed(control As IRibbonControl, ByRef toggleState)
      Select Case control.Id
        Case Is = "customButton7"
          If Not Application.ActivePresentation.SlideMaster.Shapes(Draftmaster) Then
            toggleState = True
          Else
            toggleState = False
          End If
      End Select
    End Sub
    Last edited by SamT; 06-02-2015 at 01:51 PM. Reason: Put Code Tags around code

Posting Permissions

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