RE: Table Question



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



Relevant Pages

  • Re: Table Question
    ... a user tries to open the header it goes to frmTable.Show. ... Private Sub wdApp_WindowSelectionChange(ByVal Sel As Selection) ... If ActiveDocument.AttachedTemplate ThisDocument Then Exit Sub ... Create a WindowSelectionChange that fires every time the selection is ...
    (microsoft.public.word.vba.general)
  • Re: runtime error in macro
    ... Depends which version of Excel you are using, but on my XL2K, there is no ... it would be better to set the "Header" argument to something other ... ..Selection does return what was last .selected. ... i am getting a run time error '1004' when i attempt to run this macro ...
    (microsoft.public.excel.programming)
  • Re: How to unlink headers/footers correctly without using ActiveWindow
    ... For the most part, you can avoid using the ActiveDocument, as follows. ... Then you can do almost anything with oRange that you can do with Selection. ... With regard to breaking the link between sections for the header and footer, ... As a start I ran a macro with application visible. ...
    (microsoft.public.word.vba.general)
  • Re: adding text to header
    ... the initial selection point as a reference, don't use or move the selection ... > header) for each section of a document. ... When the macro runs, it: ...
    (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)