Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

How do I run a macro exiting a field while the form is protected .

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Colin4 - 24 Jul 2007 22:32 GMT
Word 2003
My macros do not work when triggered by exiting a field while my form is
protected.
Graham Mayor - 25 Jul 2007 09:49 GMT
It depends what the macro does whether it will work or not. Some functions
are only available when the form is unlocked, so your code needs to unlock
and relock the form eg

Dim bProtected As Boolean

'Unprotect the file
If ActiveDocument.ProtectionType <> wdNoProtection Then
 bProtected = True
 ActiveDocument.Unprotect Password:=""
End If

'do your stuff

'Reprotect the document.
If bProtected = True Then
 ActiveDocument.Protect _
 Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Word 2003
> My macros do not work when triggered by exiting a field while my form
> is protected.
Colin4 - 25 Jul 2007 14:34 GMT
Graham - thank you for your extreemly prompt response - I will try your
solution this week - thanks again!

> It depends what the macro does whether it will work or not. Some functions
> are only available when the form is unlocked, so your code needs to unlock
[quoted text clipped - 19 lines]
> > My macros do not work when triggered by exiting a field while my form
> > is protected.
Graham Mayor - 25 Jul 2007 15:19 GMT
You are welcome :)
Note that if the form is password protected you will have to supply the
password between the quotes at both places. The macro as written assumes no
password.
Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Graham - thank you for your extreemly prompt response - I will try
> your solution this week - thanks again!
[quoted text clipped - 30 lines]
>>> My macros do not work when triggered by exiting a field while my
>>> form is protected.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.