Re: Table Question
- From: Russ <drsN0SPAMmikle@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 28 Jul 2007 15:13:56 -0400
LEU,
Under the line 'Case Else' you could use something like:
If Selection.InRange(bktable) then
frmTable.Show
End If
I modified the last macro from ?How can I prevent users from editing the
header of a document in Word 2000 or higher?¹ to the following below. Now if
a user tries to open the header it goes to frmTable.Show. I have Created a
bookmark range around the entire table that I don't want users to select
called ?bktable¹. How do you add a new Case that if a user clicks inside
?bktable¹ it will go to frmTable.Show or do you have to use whole new macro?
Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection)
'quit if active doc isn't attached to this template
If ActiveDocument.AttachedTemplate <> ThisDocument Then Exit Sub
'get out of the header if we're in it
Select Case Sel.StoryType
Case wdEvenPagesHeaderStory, wdFirstPageHeaderStory, wdPrimaryHeaderStory
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
frmTable.Show
Exit Sub
Case Else
End Select
End Sub
LEU
"old man" wrote:
Hi,
I wrote code to keep users out of a page in Word document by using the
WindowSelectionChange event. This approach may work for you:
1. Create a bookmarked range around the entire table that you don't want
users to select.
2. Create a WindowSelectionChange that fires every time the selection is
changed and checks if the selection is in the bookmark created in the
previous step.
2. If it is (the user has clicked in the table) do a form.show and then
after the form is closed move the selection right before the table you want
to keep the user out of.
To use this event follow the instructions at:
http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm
If you have done this before it is more important to do exactly what the
article says then understanding exacly is going on. If you create event
handlers you will soon get comfortable using this powerful feature of Word.
The WindowSelectionChange does not seem to create a real performance hit
but some of the other events can result in sluggish performance of Word.
You can copy the code from here:
http://word.mvps.org/FAQs/Customization/ProtectWord2000PlusHeader.htm and
change it to check where the current selection point is after the
WindowSelectionChange is invoked.
Old Man
"LEU" wrote:
I found out that if you protect a section of a document Shapes and Drawings
do not work unless you unprotect the document first. The only reason I was
looking at protecting section(s) was to force users to use a form that when
saved would populate the tables in the document correctly. Without
protecting
the section(s), is there a way that if a user clicks in a table to update it
will take them to my form instead to be used to edit or update the tables?
--
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
.
- References:
- RE: Table Question
- From: LEU
- RE: Table Question
- Prev by Date: Re: Unwanted dialog box in Replace macro
- Next by Date: Re: Macro to print page 1
- Previous by thread: RE: Table Question
- Next by thread: Re: Drop Down getting values from Excel
- Index(es):
Relevant Pages
|