View Single Post
 
Old 01-26-2016, 04:44 PM
joewoods joewoods is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Jan 2016
Location: Chicago
Posts: 7
joewoods is on a distinguished road
Default Macro to change all text color to black in all docx files in a selected folder

Hi guys! I'm trying to put together a macro that changes all the text to black in multiple docx files in a given folder. This is what I have.. but it's not working. Any suggestions?

Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.docx", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc
    Selection.WholeStory
    Selection.Font.Color = -587137025
    .Close SaveChanges:=True
  End With
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Reply With Quote