Convert Author-Date format to Footnotes

A place for users to ask each other questions, make suggestions, and discuss Bookends.
Jon
Site Admin
Posts: 7870
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Convert Author-Date format to Footnotes

Post by Jon » Thu Aug 03, 2017 5:13 pm

I managed to make it simpler. I think I'll stop fiddling with it now.

Jon
Sonny Software

Code: Select all

Sub CreateFootnote()
Dim oRng As Range
Dim strText As String
Dim i As Long
    Set oRng = ActiveDocument.Range
    i = 1
    With oRng.Find
        Do While .Execute(FindText:="\{(*)\}", _
                          MatchWildcards:=True)
            strText = Replace(oRng.Text, "{", "")
            strText = Replace(strText, "}", "")
            ActiveDocument.Footnotes.Add Range:=oRng, Text:=strText
            oRng.Text = ""
            i = i + 1
            oRng.Collapse 0
        Loop
    End With
    
 
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub

Jon
Site Admin
Posts: 7870
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Convert Author-Date format to Footnotes

Post by Jon » Thu Aug 03, 2017 5:15 pm

jpkell wrote:Unfortunately however, your macro produces three separate footnotes for "...{Brennan, 2007, #74498}{George, 2012, #5678}{Maddow, 1998, #1234}."
Yes. But that's not the way you should be citing them for Bookends, anyway. It works, but the preferred method is to group them all in one set of curly brackets:

{Brennan, 2007, #74498; George, 2012, #5678; Maddow, 1998, #1234}

Jon
Sonny Software

jpkell
Posts: 11
Joined: Thu Aug 03, 2017 12:31 pm

Re: Convert Author-Date format to Footnotes

Post by jpkell » Thu Aug 03, 2017 5:17 pm

I appreciate your efforts. Thanks.

jpkell
Posts: 11
Joined: Thu Aug 03, 2017 12:31 pm

Re: Convert Author-Date format to Footnotes

Post by jpkell » Thu Aug 03, 2017 5:26 pm

Jon wrote:
jpkell wrote:Unfortunately however, your macro produces three separate footnotes for "...{Brennan, 2007, #74498}{George, 2012, #5678}{Maddow, 1998, #1234}."
Yes. But that's not the way you should be citing them for Bookends, anyway. It works, but the preferred method is to group them all in one set of curly brackets:

{Brennan, 2007, #74498; George, 2012, #5678; Maddow, 1998, #1234}

Jon
Sonny Software
I think you mean:

{Brennan, 2007, #74498/ George, 2012, #5678/ Maddow, 1998, #1234}

...with slashes separating citations and not semicolons, right?

But yeah! I didn't realize that I was doing it "wrong". Still pretty new at Bookends!

Jon
Site Admin
Posts: 7870
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Convert Author-Date format to Footnotes

Post by Jon » Thu Aug 03, 2017 6:17 pm

No, I meant semicolons. At least that's the factory default for citation separators, which you can change in Preferences -> Scan & Bib to a slash, if you want. The vast majority use the semicolon default.

Jon
Sonny Software

jpkell
Posts: 11
Joined: Thu Aug 03, 2017 12:31 pm

Re: Convert Author-Date format to Footnotes

Post by jpkell » Thu Aug 03, 2017 6:22 pm

Weird. I didn't change anything from the factory settings it came with, and mine came preset to use / . I've now changed it to semicolon, which I like better.

Thanks again.

NilsMS
Posts: 52
Joined: Mon Sep 16, 2013 10:13 am

Re: Convert Author-Date format to Footnotes

Post by NilsMS » Fri Aug 04, 2017 6:30 pm

Jon wrote:
But that's not the way you should be citing them for Bookends, anyway. It works, but the preferred method is to group them all in one set of curly brackets:
Just out of curiosity: Why is the other method preferred? (due to the way my macros work, in my docs usually every citation has its own brackets)

Cheers,

Nils

Jon
Site Admin
Posts: 7870
Joined: Tue Jul 13, 2004 6:27 pm
Location: Bethesda, MD
Contact:

Re: Convert Author-Date format to Footnotes

Post by Jon » Fri Aug 04, 2017 6:36 pm

Because you must be sure there are no characters (including spaces) between them, or Bookends will think they're separate citations. Given that Word often tries to "help" when you paste in text and insert spaces, this can result in unpleasant surprises. Having all your citations in one set of curly brackets is unambiguous. I also find it easier to read and envision what the final scanned citation group will look like. But that's a personal preference.

Jon
Sonny Software

NilsMS
Posts: 52
Joined: Mon Sep 16, 2013 10:13 am

Re: Convert Author-Date format to Footnotes

Post by NilsMS » Fri Aug 04, 2017 6:38 pm

Because you must be sure there are no characters (including spaces) between them, or Bookends will think they're separate citations. Given that Word often tries to "help" when you paste in text and insert spaces, this can result in unpleasant surprises. Have all your citations in one set of curly brackets is unambiguous. I also find it easier to read and envision what the final scanned citation group will look like. But that's a personal preference.
Thanks for the clarification!

jpkell
Posts: 11
Joined: Thu Aug 03, 2017 12:31 pm

Re: Convert Author-Date format to Footnotes

Post by jpkell » Sun Aug 06, 2017 9:43 am

UPDATE: Thanks to the kindness of Graham Mayor (http://www.gmayor.com/), I finally have what I wanted.

The following code creates an MS Word macro that takes each in-text citation (e.g. "{Brennan, 2007, #74498}", or "{Brennan, 2007, #74498; George, 2012, #5678; Maddow, 1998, #1234}") and replaces it with a footnote containing the citation.

For folks (like academics) who sometimes must switch between in-text parenthetical citations and footnote citations to please book or journal editors, this will help a lot. It provides a sort of functionality that Zotero has and Bookends lacks. The trick will be to always write using in-text citations, using the macro to convert to footnotes only if needed. Note that you will want all your citations to come at the end of a sentence, as this macro will create a footnote in the middle of a sentence if you place a citation there.

So thanks to G. Mayor, and also to Stefan Blom, whose code is used in the macro to convert the footnotes into "dynamic" ones that will auto-renumber themselves when moved around (source here: http://www.msofficeforums.com/word-vba/ ... post100159

Code: Select all

Sub IntexttofootnoteGmayorSblom()

Dim oRng As Range
Dim strText As String
Dim i As Long
    'Set a range to the document body
    Set oRng = ActiveDocument.Range
    'set the initial Value for the counter
    i = 1
    With oRng.Find
        Do While .Execute(FindText:=" {", _
                         MatchWildcards:=False) 'find a space followed by an opening bracket {
            'Move the end of the range to the closing bracket
            oRng.MoveEndUntil "}"
            'move the end of the range outside the bracket }
            oRng.End = oRng.End + 1
            'Move the end of the range to encompass the period
            oRng.MoveEndWhile Chr(46)
            'The Mid(oRng.Text, 2) part removes the leading space from the footnote text
            ActiveDocument.Footnotes.Add oRng, CStr(i), Mid(oRng.Text, 2)
            'oRng.Text = ""
            'add back the period
            oRng.Text = "."
            'increment the counter
            i = i + 1
            'collapse the range to its end
            oRng.Collapse 0
            'and look for the next one
        Loop
    End With


Dim ftText As String
Dim r As Range
Dim ftCount As Long
   ftCount = ActiveDocument.Footnotes.Count
   For i = ftCount To 1 Step -1
      ftText = ActiveDocument.Footnotes(i).Range.Text
      Set r = ActiveDocument.Footnotes(i).Reference.Duplicate
      ActiveDocument.Footnotes(i).Delete
      ActiveDocument.Footnotes.Add Range:=r, Text:=ftText
   Next i
    
lbl_Exit:
    Set oRng = Nothing
    Exit Sub
End Sub

Post Reply