Detecting selection is in footnotes area

G

Gary Hillerson

I've got a piece of code that inserts a new section after the current
section, using:

With Selection
.EndOf unit:=wdSection
.Collapse direction:=wdCollapseEnd
.InsertBreak Type:=wdSectionBreakNextPage
 
D

Doug Robbins - Word MVP

Use either

Selection.Information (wdInFootnote)

or

Selection.Information (wdInFootnoteEndnotePane)


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
J

Jay Freedman

The property you need is Selection.StoryType. From the VBA help for
that property:

~~~~~~~~
This example closes the footnote pane if the selection is contained in
the footnote story.

ActiveDocument.ActiveWindow.View.Type = wdNormalView
If Selection.StoryType = wdFootnotesStory Then _
ActiveDocument.ActiveWindow.ActivePane.Close
~~~~~~~~

Actually, there are more than a dozen story types, and most of them
would cause the same kind of problem. It would be better to use a
condition like

If Selection.StoryType <> wdMainTextStory Then
' don't add the section break

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

Gary Hillerson

Great information, and easy to handle ... my kind of solution!

Thanks, Jay

g
 

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