locked
Recording Macro to change fill RRS feed

  • Question

  • Hi I have recorded a macro to change the fill of items that I select.

    The way I recorded it was:

    1. selected the shape I wanted to change the fill of

    2. clicked the record macro button

    3. filled in the information for the name etc.

    4. on the already selected item, I right clicked and choose format fill

    5. change the fill colour

    6. clicked ok

    7. stopped the macro recording

    When I run the macro it will only change the fill colour of the orignal item, not of any other item I select.  In Excel if you do that, it allows you to select an object and then change the fill of other objects by selecting them first. Is is not the same in Visio.

    Please let me know what I a missing.

    Thanks

    Rob


    Thursday, June 16, 2011 10:25 PM

Answers

  • You need to add some code that will loop through all the selected shapes:

    Dim VsoSelect As Visio.Selection
    Dim VsoShape as Visio.Shape

    Set VsoSelect = Visio.ActiveWindow.Selection

    If VsoSelect.Count > 0 Then
    for each VsoShape in VsoSelect
    VsoShape.
    next VsoShape
    else
    MsgBox "You Must Have Something Selected"
    end if

    the bit after the VsoShape. can be copied from the macro you recorded

    -- Paul Herber, Sandrila Ltd. http://www.sandrila.co.uk/ Engineering and software shapes for Visio.
    • Marked as answer by Nick Wan Wednesday, June 22, 2011 1:22 AM
    Monday, June 20, 2011 4:07 PM

All replies

  • First, this isn't excel. Second if you check the macro you will probably see that it is going for a specific shape, you will have to alter the code so that it goes after the currently selected shape.

    hth,

    al

     


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Al Edlund Visio MVP
    Friday, June 17, 2011 1:24 AM
  • You need to add some code that will loop through all the selected shapes:

    Dim VsoSelect As Visio.Selection
    Dim VsoShape as Visio.Shape

    Set VsoSelect = Visio.ActiveWindow.Selection

    If VsoSelect.Count > 0 Then
    for each VsoShape in VsoSelect
    VsoShape.
    next VsoShape
    else
    MsgBox "You Must Have Something Selected"
    end if

    the bit after the VsoShape. can be copied from the macro you recorded

    -- Paul Herber, Sandrila Ltd. http://www.sandrila.co.uk/ Engineering and software shapes for Visio.
    • Marked as answer by Nick Wan Wednesday, June 22, 2011 1:22 AM
    Monday, June 20, 2011 4:07 PM