none
Unlocking a Word 2010 document changes the selection

    Question

  • We have an application that has locked Word documents. There is a function to resize an inline shape that the user has selected. However, when the document is unlocked, the inline shape gets de-selected. So the function fails because there is no inline shape selected. If text is selected, the selection does not change.

    Is this a bug or a new "feature" in Word 2010? Word 2003 did not work this way and our function works fine there.

    A workaround is to check the selection before unlocking and then restore it after unlocking. But we'd prefer to avoid that if we can get Word to function appropriately!

    Tuesday, February 26, 2013 4:56 PM

All replies

  • Hi NoDakKathy,

    Would you please clarify your application type first? And provide some code snippet for further will make more sense.

    Have a good day,

    Tom

    Thursday, February 28, 2013 1:34 AM
  • To what kind of locking do you refer? How is the user selecting the in-line shape in the locked document?

    If you're referring to forms protection, selecting an in-line shape is only possible if the in-line shape is located in an unprotected Section of the document. And, in that case, you don't need to unprotect the document to re-size the in-line shape - you can do so by selecting it and dragging the sides/corners. This applies to both Word 2003 and Word 2010.

    Similarly, if you're referring to comments or read-only protection, you don't need to unprotect the document to re-size the in-line shape - you can do so by marking it as editable before applying the protection, so that users can resize it by dragging the sides/corners. This too applies to both Word 2003 and Word 2010.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, February 28, 2013 4:44 AM
  • I'm sorry, I didn't make myself clear. This is not related to any code running, it just happens that we use this functionality in one of our macros. The behavior is the same whether using code or not. I have a document that is protected for no changes and have marked some sections for editing by any user. In the editable area is an inline shape. If I select that shape and then unprotect the document, the shape is unselected. If I again select the inline shape and protect the document, again the shape is unselected. A text selection is unchanged when protecting and unprotecting so I don't understand why the selection changes when an inline shape is selected.

    Thanks,

    Kathy

    • Edited by NoDakKathy Friday, March 01, 2013 3:38 PM
    Friday, March 01, 2013 3:28 PM
  • See my previous answer. We're not using forms protection but protecting for "No Changes."

    Resizing a picture isn't the only reason we need to retain the selection. Another function we provide is the ability to select an inline shape and then apply our standard figure format to it which involves take the image and placing it in a table. We sometimes insert a landscape page and place it there. In order to change page orientation, the document must be unprotected. But now we don't know what the user had selected as it's no longer selected.

    The situation is complicated as we have a vsto .net application running also. That application unprotects the document and then kicks off the macro. So by the time the macro runs, the image is already unselected. For now, we are going to add to the .net code to check if an inline graphic is selected, if it is, we'll capture the range, unprotect the document and then select the range before executing the macro. This way when the macro starts the inline shape is still selected. I'd just be interested in why this behavior was changed as it didn't behave this way in Word 2003. Was it intentional or just something that happened along the way?

    Thanks,
    Kathy


    • Edited by NoDakKathy Friday, March 01, 2013 3:38 PM
    Friday, March 01, 2013 3:38 PM