none
You are not allowed to edit this selection because it is protected. RRS feed

  • Question

  • We have code to remove hyperlinks from a word document when it opens. It crashes with error "You are not allowed to edit this selection because it is protected." when a word document is attached to an email and opened there. After some time same code works fine. How to remove hyperlinks so that it works even when word doc is an attachment of an email.

    Friday, March 11, 2011 2:17 PM

All replies

  • Hi himania,

    Thanks for posting in the MSDN Forum.

    Do you want to resolve your issue via UI skills? If it is, you will receive better support when you post it in http://answers.microsoft.com/en-us/office/forum/word .

    If I have misunderstood anything, please feel free to let me know.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 14, 2011 6:07 AM
    Moderator
  • Hi,

    I want to programmatically remove the hyperlinks. We are already doing it using following code:

    object collapsedend = Microsoft.Office.Interop.Word.WdCollapseDirection.wdCollapseEnd;
                    object index = 1;

                    Range signalRange = hl.Range;
                    if (signalRange.Hyperlinks.Count > 0)
                    {
                        hl = signalRange.Hyperlinks.get_Item(ref index);
                        if (hl.Range.InlineShapes.Count > 0)
                        {
                            foreach (InlineShape item in hl.Range.InlineShapes)
                            {
                                item.Delete();
                            }
                        }
                        hl.Delete();
                        Range delR = document.CreateRange(signalRange.StoryType, signalRange.Start, signalRange.End + 1);
                        if(delR!=null)
                            delR.Delete();
                        signalRange.Collapse(ref collapsedend);
                    }

     

    But this is not working immediately when the word doc (attached to an email) is opened from email.

    Regards,

    Himani

    Tuesday, March 15, 2011 5:32 AM
  • Hi himania,

    I think perhaps computer need time to switch from Outlook to Word, so it can’t be done immediately.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 16, 2011 11:36 AM
    Moderator