locked
shape selection operation is not recorded when recording a macro RRS feed

  • Question

  • Hi frinds

    in Word 2013, via "record macro" tools, i am writing a macro which performs the following tasks for me:

    1- when i select a word, it changes the font size & color & cuts the word

    2-inserts a quick part object called "MyRectangle" in the location of cut word ( i had created a customized rectangle shape & i had saved it as an Auto-text for later use)

    3- clicks on that Auto-text ( that Auto-text be selected)

    4- paste that word into Auto-text (Add the text inside that object)

    all above steps are done fine except step 3. the problem is when i start record macro, then it's not possible to select that rectangle shape ( i mean i left click on that rectangle but noting happens & it's not selected), so i can't paste that word into that shape.

    during record macro operation, can't we select shapes? if no, so what code i can write inside the macro for selection of that shape?

    thanks in advance

    Tuesday, October 28, 2014 8:09 PM

All replies

  • Maybe this little snippet can help you. Just squeeze the bits you need into your vba macro.

    Sub test()
    With ActiveDocument.Shapes '--> One shape on the page
        .Item(1).Name '--> shows the name of the autotext box
        .Item(1).TextFrame.DeleteText '--> delete the contents of the shape
        .Item(1).TextFrame.TextRange.Text = "My new text" '--> add your own new text to the box!
    End With
    End Sub

    hth


    Maurice

    Tuesday, October 28, 2014 8:52 PM
  • Maybe this little snippet can help you. Just squeeze the bits you need into your vba macro.

    Sub test()
    With ActiveDocument.Shapes '--> One shape on the page
        .Item(1).Name '--> shows the name of the autotext box
        .Item(1).TextFrame.DeleteText '--> delete the contents of the shape
        .Item(1).TextFrame.TextRange.Text = "My new text" '--> add your own new text to the box!
    End With
    End Sub

    hth


    Maurice

    hi Dear Maurica

    sorry i am not expert in word & macro

    i write my macro here & it will be very kind of you if you write the entire syntax which i need to achieve my goal:

    Sub MyMacro()
    '
    ' MyMacro Macro
    '
    '
        Selection.Cut
        Application.Templates( _
            "C:\Users\Administrator\AppData\Roaming\Microsoft\Templates\Normal.dotm") _
            .BuildingBlockEntries("small red box").Insert where:=Selection.Range, _
            RichText:=True
    End Sub

    Tuesday, October 28, 2014 9:16 PM
  • Thanks Maurice for the sample above.

    John, for macro related issues, you can post in our MSDN forum of Word for Developers, where you can get more experienced responses:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=worddev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.

    Regards,

    Ethan Hua
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.

    Wednesday, October 29, 2014 5:06 AM
  • Thanks Maurice for the sample above.

    John, for macro related issues, you can post in our MSDN forum of Word for Developers, where you can get more experienced responses:

    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=worddev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.

    Regards,

    Ethan Hua
    TechNet Community Support


    It's recommended to download and install Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office programs.

    Hi Erhan

    i wasn't familiar with this forum.

    thanks a lot

    best regards

    Wednesday, October 29, 2014 7:14 AM
  • Cross-posted at: https://social.msdn.microsoft.com/Forums/office/en-US/9645a06d-8a34-47ad-86ac-7a2cb67d50ff/shape-selection-operation-is-not-recorded-when-recording-a-macro?forum=worddev
    For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

    There are many things the macro recorder cannot capture, Shape selection is one of them. Instead of trying to capture complex actions via the macro recorder (which is generally very limited and inflexible), you need to write code that will do as you want.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, October 29, 2014 7:27 AM
  • Cross-posted at: https://social.msdn.microsoft.com/Forums/office/en-US/9645a06d-8a34-47ad-86ac-7a2cb67d50ff/shape-selection-operation-is-not-recorded-when-recording-a-macro?forum=worddev
    For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

    There are many things the macro recorder cannot capture, Shape selection is one of them. Instead of trying to capture complex actions via the macro recorder (which is generally very limited and inflexible), you need to write code that will do as you want.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Hi paul

    i had proposed that question in office forum, then a Guy guide me to post that in MSDN forum. i wasn't familiar with MSDN forums. what's wrong with that? i just acted as it was advised

    Wednesday, October 29, 2014 9:06 AM
  • If you read the link, you'll understand no-one is saying there's anything wrong with cross-posting. All that is asked is that, when you do so, you provide links at both ends, so people don't waste time covering ground that's been covered elsewhere.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Wednesday, October 29, 2014 11:59 AM
  • If you read the link, you'll understand no-one is saying there's anything wrong with cross-posting. All that is asked is that, when you do so, you provide links at both ends, so people don't waste time covering ground that's been covered elsewhere.

    Cheers
    Paul Edstein
    [MS MVP - Word]

    ok thanks
    Thursday, October 30, 2014 11:14 AM