0

I've searched for variations on this question but haven't found anything quite like it.

I have a set of Word documents that include two types of inline citation. The first is a standard academic citation, has been inserted with Zotero, and needs to remain untouched and linked to Zotero.

The second type is plaintext and needs to be converted to a footnote at the same point, with its parentheses removed. The second type of citation always begins "(File XX_XX" where X are integers, or "(Digital file".

It would help enormously if all the citations of this second type could be converted to footnotes at once. Failing that, a macro that converts selected text to a footnote, and removes its parentheses would also work. I have now managed to record a macro that does them one by one, but if there's a way to automate the process throughout the document that would be great.

Hope you can help, and thanks in advance.

Here is a sample paragraph including both types of citation:

The second area where the Gauteng Provincial Government held institutional incumbency was over the regulation of public transport operators. The National Land Transport Transition Act of 2000 established provincial Operating Licence Boards, solely responsible for issuing route-based operating licences to all public transport operators (Cameron, 2005; Wosiyana, 2005; Palmer, Moodley and Parnell, 2017). These OLBs were made responsible for managing the conversion of old radius-based permits to route-based operating licences, as well as issuing new licences with guidance from municipal governments. By the time of Rea Vaya however the Gauteng OLB was “in administrative shambles” and had all but ceased to issue operating licences, leaving the City of Johannesburg to count Potentially Affected Operators on the basis of their receipts for as-yet unprocessed licence applications (File 03_05, BRT Phase 1a Joint Working Group on Participation Meeting Between City of Johannesburg And Taxi Industry, 26 March 2010).

The last citation needs to be a footnote that just reads:

File 03_05, BRT Phase 1a Joint Working Group on Participation Meeting Between City of Johannesburg And Taxi Industry, 26 March 2010

0

1 Answer 1

0

Something like this, but you will have to decide how much effort to put in to make it work and how much to fix up manually.

Sub NotesToFootnotes1()
'
Const matchcount As Integer = 2
Dim i As Integer
Dim r As Word.Range
Dim rStart As Word.Range
Dim fn As Word.Footnote
Dim s(1 To matchcount, 1 To 2) As String
' This uses a wildcard search which looks for 3 "groups"
' The first is a "("
' The second is the 'body' of the footnote
' The third is a ")"
s(1, 1) = "([(])(File [0-9][0-9]_[0-9][0-9]*)([)])"
' This replaces the found text by the content of the second group.
s(1, 2) = "\2"
s(2, 1) = "([(])(Digital file*)([)])"
s(2, 2) = "\2"
For i = 1 To matchcount
  Set r = ActiveDocument.Content
  With r.Find
    .Text = s(i, 1)
    .Replacement.Text = s(i, 2)
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    ' This wil actually match Digital fIle, Digital File, DIGITAL FILE etc.
    ' If you only want to match Digital file, set it to False
    .MatchCase = True
    .MatchWholeWord = False
    .MatchAllWordForms = False
    .MatchSoundsLike = False
    ' Very important!
    .MatchWildcards = True
    .Execute Replace:=True
    Do While .Found
      Set rStart = r.Duplicate
      rStart.Collapse WdCollapseDirection.wdCollapseStart
      ' Initially, create an empty footnote, because if we want to
      ' put formatted text in the footnote, we can't do it in the .Add
      With rStart.Footnotes.Add(Range:=rStart, Text:="")
        ' Don't copy the newly inserted footnote reference!
        r.Start = r.Start + 1
        ' This copies the content of the range, which would include formatting
        ' possibly images and so on. If you don't want that, use
        ' .Range.Text = r.Text
        ' instead, but be aware that anything other than text will probably not
        ' copy exactly the way you expect.
        .Range.FormattedText = r.FormattedText
      End With
      Set rStart = Nothing
      r.Delete
      .Execute Replace:=True
    Loop
    Set r = Nothing
  End With
Next ' i
End Sub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .