Re: What is the VBA for protecting a document by Ben
Ben
Thu Jun 30 05:41:42 CDT 2005
Patti, I am glad this works for you.
Word Heretic... For someone that charges money to do VBA, you sure have
problems reading plain English.
Perhaps you should re-read the question (and maybe read it again). You
might then realise that the demographic import has already been done,
leaving the original question on how to protect/unprotect the document.
It's common for people requesting *help* to set the scene in what they are
trying to achieve. This is simply what Patti did.
What part of "We _have created_ a document that puts in demographics
automatically" did you not understand??
Kind Regards, Ben
"Word Heretic" <myfullname@tpg.com.au> wrote in message
news:pa50c1dh9u9cionmioi72kfie47s8cmtk2@4ax.com...
> G'day "Patti" <Patti@discussions.microsoft.com>,
>
> So why did you ask for it?
>
>
> Steve Hudson - Word Heretic
>
> steve from wordheretic.com (Email replies require payment)
> Without prejudice
>
>
> Patti reckoned:
>
> >Ben, it works perfectly. I have the other 90%, I think
> >
> >"Word Heretic" wrote:
> >
> >> G'day "Ben M" <aa@ozemail.com.au>,
> >>
> >> Ok, so you've done 10% of the job - now finish it.
> >>
> >> Steve Hudson - Word Heretic
> >>
> >> steve from wordheretic.com (Email replies require payment)
> >> Without prejudice
> >>
> >>
> >> Ben M reckoned:
> >>
> >> >Patti,
> >> >
> >> >Here is some code that I had used to protect/unprotect a document.
You can
> >> >also use a password as I have done. I have also checked if the
document is
> >> >protected before I unprotect it etc.
> >> >
> >> >Hope this free help is of use.
> >> >
> >> >
> >> >' // --------------------------------- //
> >> >' // UnprotectDocument //
> >> >' // --------------------------------- //
> >> >
> >> >Sub UnprotectDocument()
> >> > On Error Resume Next
> >> > If ActiveDocument.ProtectionType = wdNoProtection Then
> >> > Debug.Print
> >> > Else
> >> > ActiveDocument.Unprotect Password:="password"
> >> > End If
> >> >End Sub
> >> >
> >> >' // --------------------------------- //
> >> >' // ProtectDocument //
> >> >' // --------------------------------- //
> >> >
> >> >Sub ProtectDocument()
> >> > On Error Resume Next
> >> > If ActiveDocument.ProtectionType = wdNoProtection Then
> >> > ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True,
> >> >Password:="password"
> >> > Else
> >> > Debug.Print
> >> > End If
> >> >End Sub
> >> >
> >> >The just call the sub you want.
> >> >
> >> >Call ProtectDocument 'example how to call
> >> >
> >> >
> >> >
> >> >"Patti" <Patti@discussions.microsoft.com> wrote in message
> >> >news:A256D38F-F5B0-4919-B7E8-A817569F9286@microsoft.com...
> >> >> We have created a document thatputs in demographics automatically.
In
> >> >order
> >> >> to make this work, the document cannot be protected. After the
> >> >demographics
> >> >> are fed in, I need to protect the document to make the rest of the
form
> >> >> usable to our staff. I would like to enter VBA code into an autoopen
macro
> >> >> that already feeds the demographics into the doc. My boss does not
want
> >> >staff
> >> >> to be able to touch anything but the fields. Thanks for any
assistance.
> >> >> Patti
> >> >
> >>
> >>
>