PDA

View Full Version : [SOLVED:] Convert DOS doc in-line footnotes to Word bottom of page ones - Help with Macro



Divadog
02-02-2021, 02:44 PM
Hi,I need help converting 1980s DOS word processor documents into Microsoft Word 2016 documents. Word opens these documents. Text is read as text and the formatting characters are translated as extended Ascii characters as shown here:

Historical studies are still undertaken and judged with a very different logic than are sociological ones. Conversely, sociologists who study history have quite different methodological orientations than do historians.ÀÆÏÏÔûVictoria E. Bennett, "The Uses of Theory. Concepts and Comparison in Historical Sociology", ÀÉûComparative Studies in Society and History.ý, ÀÂû22ý, 1980.ý. Apart from a more conscious concern with quantification the kind of history that is being written today seems to be little different as far as the perspective of the historical social scientist is concerned from that which was being written fifty years ago.
Italicized text, for example, is enclosed between the extended Ascii character string ÀÉû and ý, while bolding uses the characters ÀÂû and ý. Footnotes begin with the extended Ascii character string ÀÆÏÏÔû and end with the character ý preceded by a period (.). I have written the following VBA macro that converts the extended Ascii character string encased in-line footnotes into bottom of page Word footnotes:

Sub FinalWordFootnotes()
' FinalWordFootnotes Macro
Selection.Find.ClearFormatting
With Selection.Find
.Text = "&Agrave;&AElig;&Iuml;&Iuml;&Ocirc;&ucirc;*.&yacute" '<---In-line footnote enclosed in extended Ascii character stings
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
While Selection.Find.Execute
ActiveDocument.Footnotes.Add Range:=Selection.Range, Text:=Selection.Text
Wend
End With
End Sub
(Note: the text being searched for is any text between the extended Ascii character strings &Agrave;&AElig;&Iuml;&Iuml;&Ocirc;&ucirc; and..&yacute; such as: &Agrave;&AElig;&Iuml;&Iuml;&Ocirc;&ucirc;Victoria E. Bennett, &quot;The Uses of Theory. Concepts and Comparison in Historical Sociology&quot;, &Agrave;&Eacute;&ucirc;Comparative Studies in Society and History.&yacute;, &Agrave;&Acirc;&ucirc;22&yacute;, 1980.&yacute;.)

Unfortunately, this macro leaves the Ascii encased footnotes in the text. The bottom of page footnotes it creates also include the extended Ascii character strings. Accordingly I need to revise my macro so that it also:
1. Creates the in-line footnotes the Word bottom of page footnotes without the extended Ascii characters strings.
2. Once the in-line footnote has been created, delete the in-line/in-text footnote used to create it, including its extended Ascii characters.

While I programmed extensively in Excel VBA some twenty years ago, I've largely forgotten it, and I have never written Word VBA macros. I would, then, be grateful for any suggestions and advice as to how I might revise my macro in this regard. Suggestions as to how I could automatically format my documents to bottom of page footnotes using Arabic numbers before running this macro would also be appreciated. Presently I am doing it by creating a footnote using the Word References - Insert Footnote menu before I run my macro.

My thanks in advance for all your help, advice and suggestions.

macropod
02-02-2021, 05:27 PM
Cross-posted at: vba - Revise macro to convert DOS document in-line footnotes to MS Word bottom of page footnotes - Stack Overflow (https://stackoverflow.com/questions/66019356/revise-macro-to-convert-dos-document-in-line-footnotes-to-ms-word-bottom-of-page)
Please read VBA Express' policy on Cross-Posting in Rule 3: http://www.vbaexpress.com/forum/faq.php?faq=new_faq_item#faq_new_faq_item3

macropod
02-02-2021, 05:55 PM
For example:

Sub FinalWordFootnotes()
' FinalWordFootnotes Macro
Dim StrTxt As String
With ActiveDocument.Range
With .Find
.ClearFormatting
.Forward = True
.Format = False
.Wrap = wdFindContinue
.MatchWildcards = True
.Text = "&quot;"
.Replacement.Text = """"
.Execute Replace:=wdReplaceAll
.Text = "&Agrave;&AElig;&Iuml;&Iuml;&Ocirc;&ucirc;*.&yacute*&yacute;*&yacute;"
.Wrap = wdFindStop
End With
Do While .Find.Execute
StrTxt = .Text
.Text = vbNullString
ActiveDocument.Footnotes.Add Range:=.Duplicate, Text:=StrTxt
Loop
End With
End Sub




Of course, it would be preferable to convert all the .&Agrave;&AElig;&Iuml;&Iuml;&Ocirc;&ucirc; and similar strings to whatever formatting characteristics those strings are supposed to represent (as I've done with the &quot; strings) and to use a different approach that preserve that formatting in the conversion. Nevertheless, it can also be done post-conversion.

Divadog
02-03-2021, 07:13 AM
Thanks so much Paul.

Let me try this.