Prev: Delete rows in table if checkbox value in first cell equals true
Next: Delete rows in table if checkbox value in first cell equals true
From: Gary Hillerson on 16 Dec 2009 20:16 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 . . End With However, if the user has the cursor in the footnotes section at the bottom of a page and invokes this code, it generates a Bad Parameter error on the ".EndOf unit:=wdSection" statement. I need to determine if the cursor is in the footnotes section and prevent this code from running if so. I'm not sure what the best way to do that is. Any help with this? thanks in advance, Gary Hillerson
From: Doug Robbins - Word MVP on 16 Dec 2009 20:57 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. "Gary Hillerson" <garyh(a)hillysun.net> wrote in message news:691ji5t81ha68h7tshngpn5k9vn9upukpj(a)4ax.com... > 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 > . > . > End With > > However, if the user has the cursor in the footnotes section at the > bottom of a page and invokes this code, it generates a Bad Parameter > error on the ".EndOf unit:=wdSection" statement. > > I need to determine if the cursor is in the footnotes section and > prevent this code from running if so. I'm not sure what the best way > to do that is. > > Any help with this? > > thanks in advance, > Gary Hillerson
From: Jay Freedman on 16 Dec 2009 21:50 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 FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. On Wed, 16 Dec 2009 17:16:29 -0800, Gary Hillerson <garyh(a)hillysun.net> wrote: >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 > . > . >End With > >However, if the user has the cursor in the footnotes section at the >bottom of a page and invokes this code, it generates a Bad Parameter >error on the ".EndOf unit:=wdSection" statement. > >I need to determine if the cursor is in the footnotes section and >prevent this code from running if so. I'm not sure what the best way >to do that is. > >Any help with this? > >thanks in advance, > Gary Hillerson
From: Gary Hillerson on 17 Dec 2009 00:12 Great information, and easy to handle ... my kind of solution! Thanks, Jay g On Wed, 16 Dec 2009 21:50:22 -0500, Jay Freedman <jay.freedman(a)verizon.net> wrote: >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
From: Gary Hillerson on 17 Dec 2009 00:12
Thanks, Doug. On Thu, 17 Dec 2009 11:57:58 +1000, "Doug Robbins - Word MVP" <dkr(a)REMOVECAPSmvps.org> wrote: >Use either > >Selection.Information (wdInFootnote) > >or > >Selection.Information (wdInFootnoteEndnotePane) |