PDA

View Full Version : [SOLVED:] Handle Error When No Footnote



seamoon
09-04-2013, 12:52 PM
I have a script that do various fixes including converting footnotes to endnotes, the script works fine when document has a footnote but if document has no footnote then I get script error it highlights the string "ActiveWindow.View.SeekView = wdSeekFootnotes"
I guess the script needs additional If section when there's no footnotes Then skip and continue to rest of the script. How can I do this?






...
ActiveWindow.ActivePane.DisplayRulers = Not ActiveWindow.ActivePane. _
DisplayRulers
Selection.WholeStory
Selection.Font.Bold = wdToggle
Selection.Font.Bold = wdToggle
Options.DefaultHighlightColorIndex = wdNoHighlight
Selection.Range.HighlightColorIndex = wdNoHighlight
Selection.Font.Color = wdColorAutomatic
Selection.ClearFormatting
Selection.ClearFormatting
Selection.Font.Size = 12
Selection.Font.Name = "Tahoma"
ActiveWindow.View.Type = wdWebView


End With


If ActiveWindow.ActivePane.View.Type = wdPrintView Or ActiveWindow. _
ActivePane.View.Type = wdWebView Or ActiveWindow.ActivePane.View.Type = _
wdPrintPreview Then
ActiveWindow.View.SeekView = wdSeekFootnotes
Else
ActiveWindow.View.SplitSpecial = wdPaneFootnotes
End If
Selection.WholeStory
If Selection.StoryType = wdFootnotesStory Then
Selection.Footnotes.Convert
Else
Selection.Endnotes.Convert
End If
Selection.WholeStory
Selection.Font.Name = "Tahoma"
Selection.Font.Size = 12
Selection.Font.Bold = wdToggle
Selection.Font.Bold = wdToggle
Selection.Font.Italic = wdToggle
Selection.Font.Italic = wdToggle
With Selection.ParagraphFormat
.RightIndent = InchesToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceAtLeast
.LineSpacing = 2
.Alignment = wdAlignParagraphLeft
.WidowControl = False
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitRightIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0

End With

SamT
09-04-2013, 04:59 PM
SeaMoon,

Welcome to VBA Express. I changed your thread title to, IMO, a better description of the issue to possibly attract more help.

fumei
09-04-2013, 08:46 PM
1. You do NOT need to be in the View of footnotes (ActiveWindow.View.SeekView = wdSeekFootnotes) to action footnotes.

2. You can test if there are any footnotes by testing the Count of them


If ActiveDocument.Footnotes.Count > 0 Then

If there are any footnotes this returns a True, if there are none it returns a False.

seamoon
09-05-2013, 03:10 AM
It worked fine. Thank you very much for your help.