Why do I get an "Error 6124: You are not allowed to edit this section because it is protected."
when running this code on certain machines? I do not get it on my development machine. The bookmarks are associated with form fields.
Set objWordApp = CreateObject("Word.Application")
Set oDoc = objWordApp.Documents.Open(strDocPath)
oDoc.bookmarks("CustomerName").Select
objWordApp.selection = "Mr Smith"
oDoc.bookmarks("CustomerNumber").Select
objWordApp.selection = "0001"
oDoc.save
oDoc.Bookmarks("Comments").Select
oDoc.ActiveWindow.View = 1
objWordApp.WindowState = 0
objWordApp.Visible = True
oDoc.Activate
objWordApp.Activate
In a protected/restricted document you need to refer to .FormFields
instead of .Bookmarks
.
Instead of:
oDoc.Bookmarks("CustomerName").Select
objWordApp.selection = "Mr Smith"
Use:
oDoc.FormFields("CustomerName").Result = "Mr Smith"