jen11 said:
The VBA find and replace program I'm referring to is by Greg Maxey, I
will contact separately later for that issue. I have a directory of
files on art projects made out over the years. I would like to be
able to manage them better
by opening the directory and selecting all or certain files to add
content to, and also to be able to edit the added content later.
Example of added content would be a aims & ojectives paragraph and
list at the top of the page and adding on a new project elsewhere in
the docuement.
Regards,
Jen11
There was no reference to Greg's code in the thread, but there was the macro
I posted. I'm not sure how I was supposed to know you were talking about
something entirely different. However, the macro I posted could be used to
add text to the start of each document in a folder opened by the macro. Type
the paragraph(s) you wish to add in another document and save it.
Then you will need a couple of extra lines to open that document and append
its content at the start of each document opened by the macro:
Sub BatchProcess()
Dim strFileName As String
Dim strPath As String
Dim oDoc As Document
Dim sourceDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , _
"List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" _
Then strPath = strPath + "\"
End With
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
'Open the document with the typed paragraphs
Set sourceDoc = Documents.Open("D:\My Documents\Word
Documents\DocWithNewPara.docx")
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFileName = Dir$(strPath & "*.doc")
While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
'
'Insert the content of the source document at the start of the opened
document
oDoc.Range.InsertBefore sourceDoc.Range
'
oDoc.Close SaveChanges:=wdSaveChanges
strFileName = Dir$()
Wend
End Sub