Table Question

L

LEU

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?
 
O

old man

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
 
L

LEU

Hi,

I went through both the Writing application event procedures and How can I
prevent users from editing the header of a document in Word 2000 or higher.

1. I copied the macros from How can I prevent users from editing the header
of a document in Word 2000 or higher into my template like they say but I can
still get into the header. I must be doing something wrong.

2. I followed the instructions in Writing application event procedures and
created the macros and the ThisApplication. Now how do I create a bookmark
range for the whole table and then tie it to the ThisApplication?

LEU
 
L

LEU

I retried the 'How can I prevent users from editing the header of a document
in Word 2000 or higher' and it worked this time. I must have missed a line
when I copied and pasted the macros.

LEU
 
L

LEU

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
 
R

Russ

LEU,
Under the line 'Case Else' you could use something like:
If Selection.InRange(bktable) then
frmTable.Show
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top