Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    select multiple objects dialog in PPT (2002)

    I posted originaly to PowerPoint group but I guess I need a lot of VB help here:

    I would like to enhance the "select multiple objects" dialog in PowerPoint, to allow active display of selected objects, and add sorting buttons in that same box.

    Questions:

    1. Where can I find the code that will allow me to re-create (using an add-in and with macros/VB) the "select multiple objects" dialog
    2. Is it possible to create an active link dbetween the dialog box and the selected shapes in the slide (changes in the selection box will immediately display in the active slide)?

    Probably most of what I want to do, has already been done (can be done) by MS MVP developers. Where can I get standard code "pieces", to build my add-in (the VB help and library is like ancient Chinese to me!)

    Thank you
    Guillermo

  2. #2
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select multiple objects dialog in PPT (2002)

    That's a good idea, multi-select needs a lot of help. Here's my first try. I made the form modeless, which means that you can also do stuff in PP while the form is up. I don't remember if you can get events in PP, so the form does not update when PP changes, hence the Reload button and error-handling. I've attached a sample presentation and here is the form code from it: HTH --Sam
    <pre>Option Explicit
    Dim isLoading As Boolean ' Set true to disable change event

    Private Sub btnRedraw_Click()
    lstShapes.Clear
    UserForm_Initialize
    End Sub

    Private Sub UserForm_Initialize()
    Dim shpAll As Shape, shpSel As Shape
    Dim sItem As String, i As Long
    isLoading = True
    lstShapes.MultiSelect = fmMultiSelectMulti
    lstShapes.ListStyle = fmListStyleOption
    With ActiveWindow.Selection
    For i = 1 To .SlideRange.Shapes.Count ' for each shape
    Set shpAll = .SlideRange.Shapes(i)
    ' Add shape's name & if there is text, add the text
    sItem = shpAll.Name
    If shpAll.HasTextFrame Then _
    sItem = sItem & ": " & shpAll.TextFrame.TextRange.Text
    lstShapes.AddItem sItem
    If .Type = ppSelectionShapes Then ' If shapes are selected
    For Each shpSel In .ShapeRange ' See if this is one of them
    If shpSel.Name = shpAll.Name Then _
    lstShapes.Selected(lstShapes.ListCount - 1) = True
    Next shpSel
    End If
    Next i
    End With
    Set shpAll = Nothing
    DoEvents
    isLoading = False
    End Sub

    Private Sub lstShapes_Change()
    If isLoading Then Exit Sub
    Dim iShapes() As Long ' Array of indexes to the shapes to select
    ActiveWindow.Selection.Unselect
    On Error GoTo recoverMess
    With lstShapes
    Dim i As Long, j As Long, n As Long
    n = 0 ' Count the number of selected items
    For i = 0 To .ListCount - 1
    If .Selected(i) Then n = n + 1
    Next i
    If n = 0 Then Exit Sub ' Nothing selected
    ReDim iShapes(1 To n)
    j = 0
    For i = 0 To .ListCount - 1 ' lstShapes is 0-based, shapes is 1-based
    If .Selected(i) Then
    iShapes(j + 1) = i + 1 ' Add the index to the array
    j = j + 1
    End If
    Next i
    ActiveWindow.Selection.SlideRange.Shapes.Range(iSh apes).Select
    End With
    Exit Sub
    recoverMess:
    MsgBox "A error has occured!" & vbCr & "The list will be refreshed.", _
    vbExclamation, "Selection Tool Error"
    btnRedraw_Click
    End Sub

    Private Sub cmdAll_Click()
    doAll True
    End Sub

    Private Sub cmdNone_Click()
    doAll False
    End Sub

    Private Sub doAll(turnOn As Boolean)
    isLoading = True ' wait till the end
    Dim i As Long
    With lstShapes
    For i = 0 To .ListCount - 1
    .Selected(i) = turnOn
    Next i
    End With
    isLoading = False
    lstShapes_Change
    End Sub

    Private Sub btnNoText_Click()
    isLoading = True ' wait till the end
    Dim i As Long
    On Error GoTo recoverMess
    With ActiveWindow.Selection.SlideRange
    For i = 0 To lstShapes.ListCount - 1
    lstShapes.Selected(i) = True ' Unless:
    If .Shapes(i + 1).HasTextFrame Then
    If .Shapes(i + 1).TextFrame.TextRange.Text <> "" Then _
    lstShapes.Selected(i) = False
    End If
    Next i
    End With
    isLoading = False
    lstShapes_Change
    Exit Sub
    recoverMess:
    MsgBox "A error has occured!" & vbCr & "The list will be refreshed.", _
    vbExclamation, "Selection Tool Error"
    btnRedraw_Click
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  3. #3
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select multiple objects dialog in PPT (2002)

    Your first try is excellent !!! <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

    I need to study your code (I'm sure it is beyond what I can understand).

    What makes it even better is that even though the dialog is open, I can select objects from the dialog and click the sorting buttons, and "redraw" and it updates the sorted list!!! No need to close the select tool. This is very powerful!!

    1. I checked the code of your PPT with Alt-F11. I found the dialog form. But found very little visual basic. The VB in your post... Where is it?
    2. Can I add the auto open and auto close directly to your code and turn it into an add-in?

    THANK YOU VERY MUCH
    Guillermo

  4. #4
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select multiple objects dialog in PPT (2002)

    I found where the code is stored (I am a begginer <img src=/S/bash.gif border=0 alt=bash width=35 height=39> ):

    In the VB editor (Alt-F11) I went to the Forms frmMultiSelect
    Selected the text field element
    Right click "View Code" and there it is!

    I found that your example must be open in order for the macro and button to work while working with other PPT presentations

    If the ppt containing the dialog is not open, when I click the custom created button, it will call the macro, I get the Disable / Enable macros warning/prompt, but the dialog form flashes for less than a second and goes away.

    How should the macro behave if I save it as an add-in (given that I create the autoopen autoclose routines?
    Guillermo

  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select multiple objects dialog in PPT (2002)

    To create an addin, use Microsoft's Q222737 instructions. You said that you wanted to add more stuff to the tool: what did you have in mind? I am thinking of some changes so that it would be a useful tool for me: (1) use a tree view with the top-level as slides and clicking on the plus for a grouped shaped would ungroup it, or (2) have more than one column in the list to include other information, (3) allow the user to select a shape and then rename it, (3) make it into a com-addin so that the form could be resized/minimized, (4) if the correct PP events are available, update the list when the presentation changes. What did you want it to do? --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  6. #6
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select multiple objects dialog in PPT (2002)

    WOW! your userform is very powerful as it is. <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> I'll comment a an enduser (I still don't know how hard or easy is to implement what I'm going to ask for...)

    1. Tree view: this would look really cool! isn't it too complicated? I would do the simpler things first
    2. Multiple information column: very , very useful. I think of: Name, Web alt text, position of upper left corner , height widht
    3a. Rename? YES!!!
    3.b Resizeable userform? YES!!!
    4 Live link-events: complicated...(?) the redraw button works fine for the time being!

    When I started using your userform, I wished it would read the web alt text, because I frequently use that to "name" objects since it is read by the "select multiple objects" PP tool. Renaming with one click to open the dialog box, would do the job too. May be the "web alt text" can be turned on/off for display in the userform, as any of the other information...

    One feature I saw in another add in was copying the X - Y coordinates from an object and pasting them to others, to reposition all objects. That could be really easy to implement too...

    The coolest thing would be to enable drag and drop, to resort the list...

    But again, your userform works very well now. I think that displaying "web alt text" (probably a very simple modification to the VB) would make my day. Using the help I got from the lounge, I have an add-in to import pictures as files and making "web alt text" = filenames. That has helped me a lot in my work. If I could read those filenames in from your userform...

    One problem: if a selection is made on lets say slide 1, and I go to slide 2 and don't select anything, and call the userform, it will yield an error and trigger the de###### dialog. I avoid that by making sure each time I change slides, to select something first. May be an error trap would be needed there.

    I wish I could program like you!. Thank you <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>
    Guillermo

  7. #7
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select multiple objects dialog in PPT (2002)

    I forgot about the Alt Text. It is simple as you suggested, change
    <pre> If shpAll.HasTextFrame Then _
    sItem = sItem & ": " & shpAll.TextFrame.TextRange.Text</pre>

    to
    <pre> If shpAll.HasTextFrame Then
    sItem = sItem & ": " & shpAll.TextFrame.TextRange.Text
    ElseIf shpAll.AlternativeText <> "" Then
    sItem = sItem & " (" & shpAll.AlternativeText & ")"
    End If</pre>

    I see where you want to go with the rest of the items, if I have time, I'll work on it. I think that embedding an excel spreadsheed on the form instead of the listbox is the way to go. The columns would be name, alt text, text, Horizontal Position, Vertical Position, Height, Width, Rotation, and Scale. The embedded sheet is pretty much like a regular spreadsheet with ability to copy, paste, and sort. You would have a button to load the values from the spreadsheet to PowerPoint. Do we really need the multi-select feature? I would rather have just the shape selected for the current spreadsheet line. That way you would know for sure which item you were editing.

    Finally, I cannot get the error that you mentioned at the end of your post. Can you tell me exactly how to trigger it and the line of code that is highlighted when you go into debug? Thanks! --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  8. #8
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select multiple objects dialog in PPT (2002)

    Replaced code, and ... <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> ... it is getting even better!!!

    Multiple selection is very important for sorting. With the userform as it is now, I can select multiple objects re-sort them, change properties (color, font size, etc). I can even use other macros. This is such a powerful tool because you can do all that, while keeping the tool open. The redraw button is not a problem.

    Using excel sounds like a realy cool idea. If you implement the excel style dialog, there could be an error trap to tell the user that several items (rows) are selected (or none).

    I modified the userform to include a "rename" button, and an "add alternative web text" button. I attached the modified file. Check it out. <img src=/S/cool.gif border=0 alt=cool width=15 height=15>
    Guillermo

  9. #9
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select multiple objects dialog in PPT (2002)

    Good job on the mods! Plus, it failed on me so I could see the problem with my original code. ActiveWindow.Selection.SlideRange fails if nothing is selected. In the spreadsheet version, I am using a routine from PP MVP Shyam Pillai, the PP code guru instead of that bad code. Check out his site, http://www.mvps.org/skp/index.html, especially the The PowerPoint Add-in FAQ. Most everything that I know came from brute force and then looking on his web-site.
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  10. #10
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: select multiple objects dialog in PPT (2002)

    BTW, what do you mean by "I can select multiple objects re-sort them.?" I don't understand sort.

    It sounds like a better approach would be to keep the listbox and add an abbreviated properties dialog frame on the right: sort of a master-detail layout that has textboxes for name, web-text, horizontal-position, and vertical-position, so that you could change the info in the textbox instead of using the Format-Object dialog.

    What do you think? --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  11. #11
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: select multiple objects dialog in PPT (2002)

    Sam:

    Sorting would mean the position from front to back. The list you output in the userform is sorted according to that "layering". I have the 4 "sorting" (bring to front, etc) toolbar control buttons in a customized bar , always displayed, and I can use them with your tool open, "Redraw" will refresh the sorted list.
    I continued adding controls to your tool. I added a report/copy shape top-left X-Y coordinates, and a pasting to selected shapes option.

    For more extensive changes/additions, I would design a new tool. This one, as it is , has become my main "toolbox" for ceating/editing slides!

    Check it out! <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Guillermo

Posting Permissions

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