Table protection

F

Fuzzhead

I was looking at other posts and found out how to protect my headers and
footers using the information in ‘How can I prevent users from editing the
header of a document in Word 2000 or higher?’ (See below). Can you use this
same idea to protect a table in my document? I have created a bookmark range
around the entire table that I don't want users to be able to change and
called it ‘bktbl’. How do you add a new Case that if a user clicks inside
‘bktbl’ it will go to right before the bookmark or how would you add a 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/footer if we're in it
Select Case Sel.StoryType
Case wdEvenPagesFooterStory, wdEvenPagesHeaderStory, _
wdFirstPageFooterStory, wdFirstPageHeaderStory, _
wdPrimaryFooterStory, wdPrimaryHeaderStory
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Exit Sub
Case Else
End Select

End Sub

Fuzzhead
 
J

Jay Freedman

Insert another bookmark where you want the cursor to land -- before or
after the table, or anywhere else except inside the bktbl bookmark.
I'll arbitrarily use the name bkbeforetbl for it. Then modify the code
to

Case Else
If Sel.Range.InRange(ActiveDocument.Bookmarks("bktbl").Range) Then
ActiveDocument.Bookmarks("bkbeforetbl").Select
End If
End Select

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
F

Fuzzhead

Thanks Jay for the response.

It worked great when creating a new document from the template. Is there a
way to duplicate this in a converted WordPerfect document? I convert the
document and part of that is deleting the first page of the converted
document and then inserting my template which becomes the new first page.
When I do this and open VBA Editor in the ThisDocument none of the macros are
there. Is there some thing special that has to be done for those macros to
get populated into ThisDocument?

Fuzzhead
 
J

Jay Freedman

The macros are in the ThisDocument of the template. Inserting a page
(or any other part) from a template into a document doesn't carry
along the macros, or the toolbars or styles or any of the other things
that live in the template.

When you create a new document based on the template, the document
retains a link back to the template, and the macros (which are still
in the template, not in the document) are available whenever the
document is open. However, your converted WordPerfect document is
_not_ associated with your template because they don't have that
linkage.

To associate the template with an existing document, go to Tools >
Templates & Add-Ins, click the Attach button, and choose your template
to become 'the attached template' in place of whatever is already
there (probably Normal.dot, which is attached in the absence of any
other template). Then save, close, and reopen the document, and the
macros should run.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
F

Fuzzhead

Thank you for all your help. I just added the following to my conversion
macro and it did exactly what you said.

With ActiveDocument
.AttachedTemplate = "C:\MyMaster.dot"
End With

Fuzzhead
 

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