in

Quark Forums

A solution to importing Word documents with footnotes

Last post 05-11-2009 1:45 PM by allancass. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 12-27-2008 5:04 AM

    • Henry
    • Not Ranked
    • Joined on 12-25-2008
    • Posts 14

    A solution to importing Word documents with footnotes

    I've seen a couple of threads about missing or truncated footnote numbers when importing Word documents into Quark. I've experienced the same problem, and wrote a short macro for Word in Microsoft Visual Basic that helps the situation. It does two things: (see the next post for an improved version)

    - before each footnote reference in the body text, it inserts the number of the footnote and a '#' character, both in superscript

    - at the beginning of each footnote, it inserts the number of the footnote and '##'

    This way, footnote references can be easily searched for and recovered even if they get truncated during import. As a plus, superscript formatting gets preserved in the body text if imported right. '##' can be replaced by an appropriate character (I use a nonbreaking n-space).

    Here is the script itself:

    For i = 1 To ActiveDocument.Footnotes.Count

    x$ = Str$(ActiveDocument.Footnotes.Item(i).Index)

    ActiveDocument.Footnotes.Item(i).Range.InsertBefore Text:=(x$ + "##")

    s = ActiveDocument.Footnotes.Item(i).Reference.Start
    Selection.SetRange Start:=s, End:=s
    Selection.Font.Superscript = True
    Selection.TypeText Text:=(x$ + "#")

    Next

    In order to use it, in Word, go to Tools -> Macro -> Macros..., type in an appropriate name, click Create, and paste the above text between the Sub and End Sub tags. To run it, make sure the cursor is in the body text (not in the footnotes), select Tools -> Macro -> Macros..., select the macro created, and click Run.

    Hope this helps! 

  • 12-27-2008 6:35 AM In reply to

    • Henry
    • Not Ranked
    • Joined on 12-25-2008
    • Posts 14

    Re: A solution to importing Word documents with footnotes

     Here is an improvement over the above script. It actually converts footnote references (numbers) in the body text to plain numbers in superscript, and copy-pastes the footnotes to the end of the document with their number appended in front of them, with a '##' as a separator. Then, it asks the user whether to delete all footnotes. Here is the script itself:

    ' inserting plain text reference numbers and copying footnotes to the end of the document
    For i = 1 To ActiveDocument.Footnotes.Count

    x$ = Format(ActiveDocument.Footnotes.Item(i).Index)

    ActiveDocument.Footnotes.Item(i).Range.InsertBefore Text:=(x$ + "##")
    ActiveDocument.Footnotes.Item(i).Range.Copy
    s = ActiveDocument.Range.End
    Selection.SetRange Start:=s, End:=s
    Selection.TypeParagraph
    Selection.PasteAndFormat Type:=wdFormatOriginalFormatting

    s = ActiveDocument.Footnotes.Item(i).Reference.Start
    Selection.SetRange Start:=s, End:=s
    Selection.Font.Superscript = True
    Selection.TypeText Text:=x$

    Next

    ' deleting the footnotes
    If MsgBox("Conversion done. Delete footnotes?", vbOKCancel) = vbOK Then
      For i = 1 To ActiveDocument.Footnotes.Count
        ActiveDocument.Footnotes.Item(1).Delete
      Next
    End If

    To use it, in Word, go to Tools -> Macro -> Macros..., type in an appropriate name, click Create, and paste the above text between the Sub and End Sub tags. To run it, make sure the cursor is in the body text (not in the footnotes), select Tools -> Macro -> Macros..., select the macro created, and click Run. To be on the safe side, make sure that the last paragraph in the document is formatted with the Normal style.
  • 03-05-2009 6:00 AM In reply to

    Re: A solution to importing Word documents with footnotes

     You can't imagine how much you helped me. Thank you very much!!!

  • 04-06-2009 10:20 AM In reply to

    Re: A solution to importing Word documents with footnotes

    I got an Compile error saying PasteAndFormat cannot be found. How can I fix that?

    Jean-Marie Schwartz

    > Mac Pro Quad Core Intel 2.8 GHz, OS X.6.8, Quark XPress 9.2, Adobe CS5 <
  • 05-02-2009 6:01 AM In reply to

    • Henry
    • Not Ranked
    • Joined on 12-25-2008
    • Posts 14

    Re: A solution to importing Word documents with footnotes

    I'm sorry for the late reply. It seems that in your version of Word, the PasteAndFormat method is missing from the Selection object. The line containing PasteAndFormat could be changed to

    Selection.Paste

    It worked for me all right; let me know if this solves the problem.

  • 05-04-2009 3:00 AM In reply to

    Re: A solution to importing Word documents with footnotes

    Thanks for your help. Gave it a shot but I get another alert now saying syntax error at   For i = 1 To ActiveDocument.Footnotes.Count (in the if block).

    My version of Word is X for Mac. Don't know if this could prevent from running your code?

    Jean-Marie Schwartz

    > Mac Pro Quad Core Intel 2.8 GHz, OS X.6.8, Quark XPress 9.2, Adobe CS5 <
  • 05-07-2009 7:22 AM In reply to

    • Henry
    • Not Ranked
    • Joined on 12-25-2008
    • Posts 14

    Re: A solution to importing Word documents with footnotes

    Unfortunately, I have no experience with Word for Mac. Here are some suggestions:

    - make sure that the cursor is in the 'normal' text window, i.e. not in a footnote or in the notes window

    - make sure that there is at least one footnote (not endnote) in the document.

    If the script still does not work, could you help me by making sure that it is the second For that is causing problems? You might try changing the 'i' to 'j' in the If block, and see what the error message is. If it is the second For that is causing problems, then it might be worth trying to delete the 'If ...' and 'End If' lines around the For block. Let me know what happens! Thanks!

  • 05-07-2009 8:08 AM In reply to

    Re: A solution to importing Word documents with footnotes

    Hi Henry!

    First of all, thank you for the time and the patience you take for me. I appreciate it.

    Then, unfortunately it still doesn't work. I get an error saying sth like Compile error: Number of arguments [?] incorrect or property incorrect.

    Then the .Paste gets underlined (so in the 1st For). I have changed the i to j as suggested but to no avail. I have deleted the If… and End if lines as suggested with no result. Any idea why?

    Jean-Marie Schwartz

    > Mac Pro Quad Core Intel 2.8 GHz, OS X.6.8, Quark XPress 9.2, Adobe CS5 <
  • 05-11-2009 1:45 PM In reply to

    Re: A solution to importing Word documents with footnotes

     Thank you for this handy information.

    Find Duplicate Files Free - Fast Duplicate File Finder
Page 1 of 1 (9 items)
Powered by Community Server (Commercial Edition), by Telligent Systems