OfficeTips Home || VBA Section || General Section || Download Section || Privacy Policy

Understanding the new Designs Object in 2002 and 2003
 

The key to achieving this is to make use of the RowIndex property of the CommandBar object. Two constants msoBarRowFirst and msoBarRowLast are used to set the position of the created toolbar. By default a newly created docked toolbar is the positioned last in that docking area. The toolbar gets the last highest used row index set as the RowIndex property. The RowIndex property can also be an integer greater than 0 (msoBarRowFirst = 0). Interestingly you can set it to any value irrespective of whether these many toolbars exist or not. You can set it to a value 100 even though there might be only 3 toolbars in that docked position. The next toolbar created and positioned in this region will get the RowIndex property 101. The RowIndex property is used when you make a hidden toolbar visible to restore it to it's original location. When you make use of the msoBarRowFirst property to move the toolbar to the first position all other toolbars get pushed below hence their row indices increment by 1. If two toolbars share the same row index then the last positioned toolbar appears first in that row. To set the horizontal position of the toolbar in the row make use of the Left property.


 

' --------------------------------------------------------------------------------
' Copyright ©1999-2022, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------

Sub SetToolBarsToSameRow()

With Application.CommandBars

   With .Add("Custom ToolBar One")

        .Visible = True

        .Position = msoBarLeft

        .RowIndex = 1

   End With

   With .Add("Custom ToolBar Two")

        .Visible = True

        .Position = msoBarLeft

        .RowIndex = 1

   End With

End With

End Sub

 


A verb is an action undertaken by an OLE object to activate it's contents. Examples of various verbs are 'Open', 'Edit', 'Play' etc. You can list out the verbs associated with an OLE object using the items in the ObjectVerbs collection. Whenever an OLE object is double-clicked the default verb - the first verb in the collection gets performed. In case of MS Graph objects this verb is the 'Edit' verb. This opens up a window within the parent application - PowerPoint in this specific case. However there maybe instance when you need to open up the graph in a separate window of it's own. In that case you need to activate the 'Open' verb. Code snippet below illustrates the same. DoVerb is the method used to activate a particular verb of the OLE object. It accepts the index value of the verb within the ObjectVerbs collection and performs the associated verb. If no argument is passed it defaults to 1. In this example, we pass 2 which is the index value of the 'Open' verb.

Top


' --------------------------------------------------------------------------------
' Copyright ©1999-2022, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------




        
Sub ListVerbs()

Dim oVerb As Variant
' Assuming that the 2nd shape on the slide is an OLE object



With ActivePresentation.Slides(1).Shapes(2).OLEFormat

    For Each oVerb In .ObjectVerbs

        Debug.Print oVerb

    Next

End With

End Sub

Sub OpenInWindow()

' Assuming that the 2nd shape on the slide is an MS Graph object



With ActivePresentation.Slides(1).Shapes(2).OLEFormat

    .DoVerb 2 ' Open Verb

End With

End Sub

 

 

 

Copyright 1999-2022 (c) Shyam Pillai. All rights reserved.