-
If all the template files are in one folder, then it is easy.
Make a Sub of whatever it is you are doing for each file.
Use Dir at that folder location, with *.dot (instead of the commonly used *.doc). Then call the sub for each file. Simple. Like this:[vba]Sub CheckMyDir()
Dim path As String
Dim strFile As String
Dim getFile
path = "c:\myfiles\"
getFile = Dir(path & "*.dot")
Do While getFile <> ""
strFile = path & getFile
Documents.Open Filename:=strFile
Call DoSomething(strFile)
With ActiveDocument
.Save wdSaveChanges
.Close
End With
getFile = Dir
Loop
End Sub
Sub DoSomething(strIn As String)
' whatever it is you are doing
' With ActiveDocument.Sections(1) _
' .Headers(wdHeaderFooterPrimary)
' .Range.Delete
' .Range.Text = "Yahhooooooo!"
' End With
MsgBox strIn
End Sub[/vba]This looks for each file with .dot, and sends the full path and filename of the found file to the Sub DoSomething.
Above, DoSomething will just display the full path and name for each .dot file in the folder myFiles. But I commented a possible change. It could delete the existing header for Section 1 (Primary) and replace it with "Yahoooo!" So every .dot file in myFiles would have this performed on it.
It does not matter, it is just another procedure.
Also attaching a VERY simple demo of a multiple content file that removes "chunks" depending on user selection. Note: this is NOT a template file, but a document file. I am doing it this way simply to make it easier to look at.
All explanation on use are on the userform.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules