Loss of F2 & F8 key functionality when using a class

T

Tim

I have developed an fairly extensive set of macros to control editing of
documents in Word. One of the requirements is to prevent editing of the
headers, footers, etc... I have developed a class that I instantiate everytime
a document tied to my template is opened
(AutoOpen that calls the CheckClass routine).

This works great except that I find that some of Words native keystrokes no
longer
work. Examples are the "F2" and the "F8" keys.

Appreciate all Help.

Tim

Sub CheckClass() 'Re-initializes Class if not found
If wdApp.MyWord Is Nothing Then
Set wdApp.MyWord = Word.Application
End If
End Sub

'Re-directs entry into a headers to the appropriate Header dialog, prevents
entry into footers
Private Sub MyWord_WindowSelectionChange(ByVal Sel As Selection)
If IsObjectValid(Sel) = False Then Exit Sub
If Sel.StoryType = wdMainTextStory Then Exit Sub
If ActiveDocument.AttachedTemplate <> ThisDocument Then Exit Sub
On Error GoTo ErrTrap
Select Case ActiveWindow.ActivePane.View.SplitSpecial
Case wdPaneComments, wdPaneCurrentPageHeader, _
wdPaneEndnoteContinuationNotice, wdPaneEndnoteContinuationSeparator, _
wdPaneEndnotes, wdPaneEndnoteSeparator, wdPaneEvenPagesFooter, _
wdPaneEvenPagesHeader, wdPaneFirstPageFooter, wdPaneFirstPageHeader, _
wdPaneFootnoteContinuationNotice, wdPaneFootnoteContinuationSeparator, _
wdPaneFootnotes, wdPaneFootnoteSeparator, wdPanePrimaryFooter,
wdPanePrimaryHeader
ActiveWindow.ActivePane.Close
ActiveWindow.View = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Application.ScreenRefresh
End Select
Select Case Sel.StoryType 'If within a Header or Footer, then Exit
Case wdEvenPagesFooterStory, wdEvenPagesHeaderStory, _
wdFirstPageFooterStory, wdFirstPageHeaderStory, _
wdPrimaryFooterStory, wdPrimaryHeaderStory
ActiveWindow.View = wdPrintView
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Application.ScreenRefresh
Forms.Header 'Routine that provides dialog to entry Header Info
End Select
Exit Sub
ErrTrap:
If Err.Number = 5825 Then Exit Sub 'Object has been deleted.
MsgBox Err.Number & ", " & Err.Description
End Sub
 
J

Jezebel

There's nothing in the code you've posted (nor in code generally) that would
trap or redirect the F2 and F8 keys. More likely, they've simply been
inadvertently reassigned within your template. Open your template and try
assigning them to something else ... it will tell you what they are
currently assigned to.


Separately, I'm dubious about the effectiveness of your approach --

a) given how often WindowSelectionChange is called, you'll surely need a
fairly fast computer for the performance impact to be acceptable

b) users can obviously bypass it by disabling macros

c) unless I've missed something, it won't work if they View > Headers while
in normal view, because the ActivePane object is valid only in Print view.
 
T

Tim

Jezebel,

Thanks for your response.

There is nothing in this template that traps or redirects the F2 or F8 key.
I will try to explain in more detail.
F8 - does turn the extend mode ON as indicated with the "EXT" on the status
bar
If I right arrow, it triggers the SelectionChange event.
As soon as it enters this event, the extend mode is cancelled.
If I insert "MsgBox Selection.ExtendMode" as the first line of the event,
it always returns False.

Response to a)
For the individuals that use this template, there hasn't been any complaints
regarding performance. I am also open for other methods for preventing
editing of headers & footers.

Response to b)
Yes users can bypass it by disabling macros but it hasn't became an issue so
far.
Is there a way to prevent disabling macros?

Reponse to c)
This event is triggered when in Normal view.
When in Normal view, it drops down to the following line: Select Case
Sel.StoryType
Then If one of the StoryTypes is True,
it sets the view to PrintView, sets the pane back to the MainDocument, then
calls
the Forms.Header routine that displays a form.

Your response is greatly appreciated.
I look forward to any other ideas that you may have.

Thanks Again,

Tim
 
J

Jezebel

Not sure what's going on with your keys and all. What versions of Word are
you using? -- the events that trigger SelectionChange are different between
Word 2000 and Word 2003.

No, there's no way to prevent disabling macros ... think what the virus
writers would do if you could!
 
T

Tim

I am using Word 2000, but I have also tried this is Word 2003 with the same
result.
 

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