“You are not allowed to edit this selection because it is protected.” but only since Office 2013?

后端 未结 8 1628
我寻月下人不归
我寻月下人不归 2021-02-19 20:07

We\'ve had these few lines of code running happily in our applications for several years (and in several versions of Office, 2003, 2007, 2010 etc). Purpose is to perform a kind

8条回答
  •  感情败类
    2021-02-19 20:42

    Tried most of the suggestions above but I found this fixed the problem. We were opening the doc as a template in read-only with a password. So couldn't use 'Add'

    Documents.Open(strTemplateDoc, ReadOnly:=True, PasswordDocument:=strDocPassword, Visible:=False)

    Setting the View.Type to wdNormalView stopped the error "You are not allowed to edit this selection because it is protected"

    wdDocPage.ActiveWindow.View.Type = Microsoft.Office.Interop.Word.WdViewType.wdNormalView
    

    Thanks to all the others for their suggestions - they helped a lot.

提交回复
热议问题