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 / August 2006

Tip: Looking for answers? Try searching our database.

How do I get out of my protected Section?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brendan - 16 Aug 2006 16:39 GMT
I am using the code of "ActiveDocument.Sections(1).ProtectedForForms = True"
to protect page 1 which works fine.  On the last form field I call a macro on
exit to go to a bookmark on page 2.  This macro was tested and works fine as
long as the document is not protected.  However, once the above code is run
on the AutoNew, and once I exit the field to go to the bookmark, my cursor
simply goes to the first field on Page 1 and not to the bookmark on page to.  

Is there a line of code I need to insert in the my macGoToNarr bookmar that
allows me to go to page 2 from the protected section in page 1?
Jonathan West - 16 Aug 2006 17:20 GMT
>I am using the code of "ActiveDocument.Sections(1).ProtectedForForms =
>True"
[quoted text clipped - 11 lines]
> that
> allows me to go to page 2 from the protected section in page 1?

Is there a section break between pages 1 and 2?

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Brendan - 16 Aug 2006 17:37 GMT
Yes.  Section break is outside the table at the bottom of page1.  There is
only one in the template.

"Jonathan West" wrote:
> Is there a section break between pages 1 and 2?
Brendan - 16 Aug 2006 18:45 GMT
I can do it with the following code:

ActiveDocument.Sections(1).ProtectedForForms = False
ActiveDocument.Unprotect

but that unprotects the whole document.

So I need to reprotect Section 1 after the user gets to the narrative on
page 2.   Basically, anytime the user is on page 1, section 1 needs to be
protected.
Jean-Guy Marcil - 16 Aug 2006 21:11 GMT
Brendan was telling us:
Brendan nous racontait que :

> I can do it with the following code:
>
> ActiveDocument.Sections(1).ProtectedForForms = False

Unless the sections that need protecting are change dynamically, you do not
need this line in your code.

Just manually assign which section needs protection when you create the
template, then only use

   ActiveDocument.Unprotect

to protect/unprotect the whole document. Only the sections  labelled as "To
be protected" will be affected.

> but that unprotects the whole document.
>
> So I need to reprotect Section 1 after the user gets to the narrative
> on page 2.   Basically, anytime the user is on page 1, section 1
> needs to be protected.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Jean-Guy Marcil - 16 Aug 2006 21:11 GMT
Brendan was telling us:
Brendan nous racontait que :

> I am using the code of "ActiveDocument.Sections(1).ProtectedForForms
> = True" to protect page 1 which works fine.  On the last form field I
> call a macro on exit to go to a bookmark on page 2.  This macro was
> tested and works fine as long as the document is not protected.

Show us your code.

> However, once the above code is run on the AutoNew, and once I exit
> the field to go to the bookmark, my cursor simply goes to the first
[quoted text clipped - 3 lines]
> bookmar that allows me to go to page 2 from the protected section in
> page 1?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Brendan - 16 Aug 2006 21:37 GMT
Here is the code.  It will take me to the bookmark on Page 2 but if the user
needs to go back to page 1 and make some changes to the form fields, then the
document is left unlocked.  I could always put a macro button on the toolbar
that locks and unlocks the document but I am trying to make this as autmated
as possible to where no matter what, Page 1, with a section brake at the
bottom, is always protected and that if the user clicks in the table on page
2 (or anywhere other than page 1) for the narrative, the document he/she is
allowed to start typing.

Sub macGoToBMPropNarr()

' Checks to see if document is unprotected already

If ActiveDocument.Sections(1).ProtectedForForms = True Then
   ActiveDocument.Sections(1).ProtectedForForms = False
   ActiveDocument.Unprotect
End If

If ActiveDocument.Bookmarks.Exists("swPropNarr") Then
   ActiveDocument.Bookmarks("swPropNarr").Select
End If

End Sub
Jean-Guy Marcil - 17 Aug 2006 16:07 GMT
Brendan was telling us:
Brendan nous racontait que :

> Here is the code.  It will take me to the bookmark on Page 2 but if
> the user needs to go back to page 1 and make some changes to the form
[quoted text clipped - 20 lines]
>
> End Sub

As I wrote in my other reply in this thread, if you set up your template
properly, all you need is
   ActiveDocument.Unprotect

Now, in your code, you are unprotecting the document.
May I ask why?
Also, you are not re-protecting it, so of course, section 1 is now
unprotected.

I have the feeling that all you want to do is send the user to the beginning
of the editable part of the document when they are done typing in the
formfields. If this is the case, then you do not need a macro.
Just protect section 1 (and not section 2) and then the cursor will
automatically go to the beginning of section 2 when they tab out of the last
field in section 1.

Now, if you really need a macro, try this:

Sub macGoToBMPropNarr()
   Application.OnTime When:=Now, Name:="ReallymacGoToBMPropNarr"
End Sub

Sub ReallymacGoToBMPropNarr()
   If ActiveDocument.Bookmarks.Exists("swPropNarr") Then
       ActiveDocument.Bookmarks("swPropNarr").Select
   End If
End Sub

It seems that without the macro to call another macro, Word will not
properly get to the bookmark.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Brendan - 17 Aug 2006 17:03 GMT
That worked perfectly.  Thank you very much.  I can now leave the document
protected with Section(2) unprotected.  I don't know why Word did not like
simply executing the "ReallymacGoToBMPropNarr()" on its own.

Brendan

> Sub macGoToBMPropNarr()
>     Application.OnTime When:=Now, Name:="ReallymacGoToBMPropNarr"
[quoted text clipped - 8 lines]
> It seems that without the macro to call another macro, Word will not
> properly get to the bookmark.
 
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.