Consulting

Results 1 to 4 of 4

Thread: Handle Error When No Footnote

  1. #1
    VBAX Regular
    Joined
    Sep 2013
    Posts
    10
    Location

    Handle Error When No Footnote

    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

  2. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    SeaMoon,

    Welcome to VBA Express. I changed your thread title to, IMO, a better description of the issue to possibly attract more help.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    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.
    Last edited by fumei; 09-04-2013 at 09:21 PM.

  4. #4
    VBAX Regular
    Joined
    Sep 2013
    Posts
    10
    Location
    It worked fine. Thank you very much for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •