Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-27-2021, 11:37 AM
rgsl111 rgsl111 is offline Take footnotes from source and put into new template Windows 10 Take footnotes from source and put into new template Office 2016
Novice
Take footnotes from source and put into new template
 
Join Date: Oct 2021
Posts: 5
rgsl111 is on a distinguished road
Default Take footnotes from source and put into new template

I've been working on piecing together a program thanks to a high school VBA class many years ago and searching through websites that, among other things, takes an "outside" document, pastes it as unformatted text into a blank template, and runs through a number of mostly find/replace functions. Problem is that it doesn't bring over footnotes. I was able to get it to insert the in-paragraph footnote marks and currently have it pasting the content of the footnotes at the end of the document to be manually placed, but I'm trying to be able to get it to insert the content into its corresponding footnote, but it is a good bit above my ability (and a good bit of this is probably fairly inefficient, but I don't get any errors, so I don't question it).

I suppose I should start with a background of the process that this is being used for. Without going into too much detail, I work in a Word Processing department where we take agreements, letters, court documents, etc. that we receive from outside sources and "format" the documents using our own in-house styles and numbering suite (Innova). Directly formatting the documents we receive have caused many problems in the past where functions of the numbering suite, table of contents, and revising don't work as they normally should, so we have made it our standard procedure to copy and paste special as unformatted text into our "templates" most of the documents we receive and then apply our styles and numbering to this "fresh" document. Originally, the main purpose of this program was simply to use find/replace and insert non-breaking spaces and hyphens. It eventually snowballed into something that would do the entire copy/paste process for us, retaining bold, italics, underline, and highlighting using find/replace, as well as inserting the non-breaking characters and other department specific actions. Since we adopted this copy/paste standard, there was always the problem of footnotes not being brought over, thus that was the next thing on the list to be added to the ever-growing script.

Here is what is have so far:

Code:
Private Sub CommandButton1_Click()

With ActiveDocument

.AutoHyphenation = False

With .Range
With .Find

Dim xRange As Range
Set xDoc = ActiveDocument
If xDoc.Footnotes.Count > 0 Then
Set xRange = xDoc.Footnotes(1).Range
xRange.WholeStory
xRange.Select

ActiveDocument.Paragraphs.Add
ActiveDocument.Content.InsertAfter "Footnotes"
ActiveDocument.Paragraphs.Add

Selection.Copy
Set Range2 = ActiveDocument.Content
Range2.Collapse Direction:=wdCollapseEnd

Range2.Paste

.Text = "^f"
.Replacement.Text = "<footnote>"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Replacement.ClearFormatting
.Format = True
.Forward = True
.MatchWildcards = True
.Wrap = wdFindContinue
.Font.Underline = True

End If
End With
End With

Dim wholeDoc As Document
Dim wholeRange As Range
Set wholeDoc = ActiveDocument
Set wholeRange = wholeDoc.Range(Start:=0, End:=0)
wholeRange.WholeStory
wholeRange.Select
Selection.Copy
Set Range3 = ActiveDocument.Content
Range3.Collapse Direction:=wdCollapseEnd
Application.ScreenUpdating = False
Application.ScreenUpdating = True

.Text = ""
.Replacement.Text = "<u>^&</u>"
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Highlight = True
.Replacement.Text = "<h>^&</h>"
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Font.Bold = True
.Replacement.Text = "<b>^&</b>"
.Execute Replace:=wdReplaceAll
.ClearFormatting
.Font.Italic = True
.Replacement.Text = "<i>^&</i>"
.Execute Replace:=wdReplaceAll

End With

Documents.Add ("12pt Template")

With ActiveDocument
Set myRange = Selection.Range
myRange.WholeStory
Selection.PasteSpecial DataType:=wdPasteText

EmphasisFormatClean

WPDFormat

End With
Unload Me

End Sub
Any help is greatly appreciated! Thank you!
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Request for a macro to move footnotes (not formatted as footnotes) from end of page to end of doc Pluckedchicken Word VBA 0 09-03-2020 05:21 AM
Take footnotes from source and put into new template How to change superscript footnotes into genuine Word footnotes Knounte29 Word VBA 41 01-16-2020 04:48 PM
creating manuscript w/footnotes from separate documents containing chapters with footnotes-word 2010 Dottie Publisher 0 02-19-2017 03:18 PM
Convert manual cross references in footnotes to other footnotes to automatic cross references ghumdinger Word VBA 7 11-20-2014 11:47 PM
Edit Data Source- Linking template charts to new data lbf PowerPoint 0 10-28-2011 12:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:03 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft