none
deselect selected shape in word vba RRS feed

  • Question

  • Hi,

    Through program, I select a text box for a purpose and i need to deselect the selected shape to continue the process, How can i deselect a selected text box(shape)? Is there any way to accomplish this?

    Thanks in advance
    Aish
    Thursday, February 18, 2010 11:23 AM

Answers

  • Hello,

    If you are working on Word 2003 we could de-select the selection by following code:

       Selection.Collapse

    If it is Word 2007 which Textbox is now become a ContentControl, we could move the cursor out the selection range by following code:

         'the parameter "Count" depends on your scenario.
        Selection.MoveRight Unit:=wdCharacter, Count:=2

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Tim Li Wednesday, February 24, 2010 7:45 AM
    Wednesday, February 24, 2010 7:44 AM

All replies

  • Hi,
    what about creating another text box and deleting it?

    ActiveDocument.Shapes.AddTextbox msoTextOrientationHorizontal, 20, 20, 20, 20
    ActiveDocument.Shapes(ActiveDocument.Shapes.Count).Delete

    Jiri

    Thursday, February 18, 2010 12:02 PM
  • Hi,

    I tried it. Still the text box remains selected. Any another suggestions please..

    Thanks
    Aish
    Monday, February 22, 2010 5:08 AM
  • Try to add another line where you select the newly created textbox so the final code looks like this
    ActiveDocument.Shapes.AddTextbox msoTextOrientationHorizontal, 20, 20, 20, 20
    ActiveDocument.Shapes(ActiveDocument.Shapes.Count).Select
    ActiveDocument.Shapes(ActiveDocument.Shapes.Count).Delete

    Jiri
    Monday, February 22, 2010 8:31 AM
  • I would think you can just select a word or paragraph in the document.  That should deselect any shape.  I have done this in excel not word.
    Monday, February 22, 2010 7:39 PM
  • Hello,

    If you are working on Word 2003 we could de-select the selection by following code:

       Selection.Collapse

    If it is Word 2007 which Textbox is now become a ContentControl, we could move the cursor out the selection range by following code:

         'the parameter "Count" depends on your scenario.
        Selection.MoveRight Unit:=wdCharacter, Count:=2

    Thanks.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Tim Li Wednesday, February 24, 2010 7:45 AM
    Wednesday, February 24, 2010 7:44 AM