RE: List of cross-references based on custom style
- From: Bear <Bear@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 17 Apr 2007 06:20:04 -0700
Jennifer:
Perhaps this might be of some help to you.
I use a modeless userform for my Insert Cross-Reference dialog box. I don't
use the "magic" forms approach, although I've never experienced any problems
that I could attribute to magic forms with certainty.
So my InsertCrossReference() sub deletes then creates a new instance of the
userform class each time it's invoked. Here's how.
~~~~~
Sub InsertCrossReference()
' Traps Word InsertCrossReference command and opens the
' Insert Cross Reference dialog box. Special coding is used
' for this nonmodal dialog form.
' Delete any instances and create a new instance
If Not objInsertCrossReference Is Nothing Then
Set objInsertCrossReference = Nothing
End If
Set objInsertCrossReference = New frmInsertCrossReference
objInsertCrossReference.Show
End Sub
~~~~~
The form persists between invocations, so it must be destroyed at the end of
the Word session. I do this in an AutoExit sub.
~~~~~
Public Sub AutoExit()
'MsgBox "AutoExit event from Custom Tools"
' Destroy modeless forms
....
[I destroy several modeless forms here, including the X-ref one.]
....
If Not objInsertCrossReference Is Nothing Then
Set objInsertCrossReference = Nothing
End If
' Destroy session-durable forms
If Not objInsertTable Is Nothing Then
Set objInsertTable = Nothing
End If
End Sub
~~~~~
All the other code -- though this may not be the best practice -- is in the
userform. That's where already-created code would help you most, but that's
the area where I can't help you much, because the application is so
different. You already know what type of x-ref you're looking for, etc. But
do let me know how you sort out the appendix numbered items from the other
items in GetCrossReferenceItems, won't you?
And think about your custom dialog box some more. Why not include chapters
and topics? Your dialog could let the user choose between short lists of
chapters, appendices, or topic titles. That way the dialog makes more "sense"
as a custom tool -- it makes the most frequently used x-refs available.
You could phase it in -- putting the requisite conrols in place but leaving
them all disabled except the Appendix ones. Then you enable them as you add
the code.
Enough daydreaming. Back to work.
Bear
.
- Follow-Ups:
- RE: List of cross-references based on custom style
- From: Jennifer H
- RE: List of cross-references based on custom style
- Prev by Date: Re: Using VBA to set "Disable features introduced after" to false.
- Next by Date: Re: Toolbar Buttons
- Previous by thread: Re: Insert Page break after last period in copied/pasted text.
- Next by thread: RE: List of cross-references based on custom style
- Index(es):