Re: Table Question



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

.



Relevant Pages

  • RE: Table Question
    ... I modified the last macro from ‘How can I prevent users from editing the ... a user tries to open the header it goes to frmTable.Show. ... Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection) ... Create a WindowSelectionChange that fires every time the selection is ...
    (microsoft.public.word.vba.general)
  • Re: What is happening? Headers and Footers Q
    ... Help says that, when you invoke this, "If the selection is in a header, ... thinks is the 'next' header or footer, which may or may not be in the ... Sub DeleteHAndFAtTheSelection() ...
    (microsoft.public.word.vba.general)
  • Re: What is happening? Headers and Footers Q
    ... says that, when you invoke this, "If the selection is in a header, this ... method moves to the next header within the current section (for example, ... thinks is the 'next' header or footer, which may or may not be in the ... Sub DeleteHAndFAtTheSelection() ...
    (microsoft.public.word.vba.general)
  • Re: C#, ADO.NET and MS-SQL
    ... > Layout of Order header, a supplier is required and Items will be ordered. ... selection of Ledger and Supplier. ... > Will the DataAdapter/DataSet be in a position to use the Update, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: VBA Template Form
    ... contact from Outlook at the location of the selection and the name of the ... selected contact in the primary header of the first Section of the document, ... from the Outlook address book. ... Dim strAddress As String ...
    (microsoft.public.word.vba.beginners)