How do I change the font on an entire folder?

V

Veronica

I have changed my normal template to reflect a new font. I have old
documents which are in multiple folders. I need to know how to change the
entire folder without having to go into each document to change the font. I
have gone into some of the documents and changed the font and saved it, but
when I try to insert one of these documents into a new document, the font
reverts back to the old one, even after I have saved it to the new font. I'm
totally confused!!
 
G

Graham Mayor

If you make changes to the normal template those changes are applied to new
documents created from the template. Existing documents are designed to try
and retain the formatting they contain.

You cannot make changes to a document without opening it, but you could open
all the files in a folder with a batch processing macro. The problem with
this is that unless you know exactly what those documents contain and in
what way you want them changed, such a macro likely to produce unexpected
results.

If the documents have been correctly formatted with styles then it would be
simple enough to alter the style formats. If they have been manually
formatted it will be a hotch potch.

Why do you need to change all these old files? Wouldn't it be simpler to
change them on an ad hoc basis as and when you require them?

The basic batch processing code is as follows. The currently active document
would be oDoc. You could, for example add the command
oDoc.Range.Font = "Times New Roman"
where indicated, and it would (depending on the complexity of the document
layout) format the document with the Times New Roman font. Font enhancements
such as size, bold etc would not be changed, and but I would urge you to try
it on a new folder containing copies of a few sample documents.
http://www.gmayor.com/installing_macro.htm

Sub BatchProcess()
Dim strFileName As String
Dim strPath As String
Dim oDoc 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
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)
'
'Do what you want with oDoc
'
oDoc.Close SaveChanges:=wdSaveChanges
strFileName = Dir$()
Wend
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top