Jay, I am still struggling to create a form in MS Word 2003 (XP). I want to
use a macro button that allows a user to save/close a document and one that
routes it.
I tried using a macrobutton, but run into the protected/unprotected
minefield. I double click on the macrobutton and nothing happens. :-)
Public Sub SaveIt()
'
With ActiveDocument
If .ProtectionType <> wdNoProtection Then
.UnProtect Password:=""
End If
End With
'
'Enable ENTER key on exit
Application.Run MacroName:="ReinstateEnterKey"
MsgBox Prompt:="SAVES and CLOSES supplier maintenance document, but
does not route it."
If ActiveDocument.Saved = False Then ActiveDocument.SaveAs
ActiveDocument.protect Type:=wdAllowOnlyFormFields, _
NoReset:=True, Password:=""
'Close saved supplier maintenance form
ActiveDocument.Close
End Sub
--
DJELLIOTT
"Jay Freedman" wrote:
> There shouldn't be any problem getting a macrobutton to run a macro,
> even in a protected form. The problem is that the macro can't make any
> changes to the document outside the form fields while the protection
> is turned on.
>
> To work around this, set up your macro like this:
>
> Sub DoSomething()
> With ActiveDocument
> If .ProtectionType <> wdNoProtection Then
> .Unprotect Password:="myPassWord"
> End If
> End With
>
> ' make your formatting changes here
>
> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
> NoReset:=True, Password:="myPassWord"
> End Sub
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
>
> On Wed, 20 Sep 2006 13:03:01 -0700, Diana Morrison
>
>
> >I have created a form that a manager completes. I created a macro that
> >changes the font to one colour, creates a header and saves to a certain file.
> > It's run from a macro button on the end of the form. However, if the form
> >is locked, i can't run it. Is there a way in the macro to first unlock the
> >form, then run the macro, then password protect the form again?
>