Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Loss of F2 & F8 key functionality when using a class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim - 02 Feb 2005 18:49 GMT
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

Signature

Tim Shaffer

Jezebel - 03 Feb 2005 03:38 GMT
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.

> 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
[quoted text clipped - 54 lines]
> MsgBox Err.Number & ", " & Err.Description
> End Sub
Tim - 03 Feb 2005 20:47 GMT
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

> 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
[quoted text clipped - 50 lines]
> MsgBox Err.Number & ", " & Err.Description
> End Sub
Jezebel - 03 Feb 2005 22:01 GMT
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!

> Jezebel,
>
[quoted text clipped - 100 lines]
>> MsgBox Err.Number & ", " & Err.Description
>> End Sub
Tim - 03 Feb 2005 23:27 GMT
I am using Word 2000, but I have also tried this is Word 2003 with the same
result.

> 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
[quoted text clipped - 107 lines]
> >> MsgBox Err.Number & ", " & Err.Description
> >> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.