VBA User Forms Error Message 4605

T

Tisha

I'm having some buggy problems with 2 macros that I
created in a protected form file. The fields in the
locked area are working properly, but I created 2 keyboard
macros (control+L and control+Y) that will insert a new
row in an unlocked area of the document based on the
formatting of other rows also in an unlocked portion of
the document. This insert row function works fine when the
document is unprotected, but when I turn protection on to
prevent any manipulation of locked cells, the following
visual basic debug error message is generated:

Run-time error '4605':
This method or property is not available because the
document is a protected document.

This document MUST BE protected, as certain information
cannot be altered in any way. Can anyone help me
troubleshoot this problem?
 
J

Jay Freedman

Hi, Tisha,

Lots of things are disabled in a protected document, even when you're
working in an unprotected section. The workaround for most of them is to set
up the macro so that it unprotects the document, does whatever work is
required, and then reprotects the document/sections with the parameter
NoReset:=True.

Code samples are at
http://word.mvps.org/FAQs/MacrosVBA/ChangeProtectHeader.htm (for the simpler
case where the whole document is protected at the start) and
http://word.mvps.org/FAQs/MacrosVBA/SpellcheckProtectDoc.htm (for the more
complicated case where each section has to be treated separately).
 
P

Perry

in yr macro go:

Sub MyMacro()
'unprotect the document
ActiveDocument.Unprotect

'<<your actions go here>>

'reprotect document
ActiveDocument.Protect wdAllowOnlyFormFields
End Sub

If this doesn't remedy, kindly include some code snippets
when you repost.

Krgrds,
Perry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top