Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2016, 05:34 PM
macropod's Avatar
macropod macropod is offline Macro to change all text color to black in all docx files in a selected folder Windows 7 64bit Macro to change all text color to black in all docx files in a selected folder Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:


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 <> ""
  If ThisDocument.FullName <> strFolder & "\" & strFile Then
    Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
    With wdDoc
      .Range.Font.ColorIndex = wdBlack
      .Close SaveChanges:=True
    End With
  End If
  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
Note: I don't really recommend changing font colours directly; it's much better to redefine the colours in the Styles (assuming that's how the colours have been applied). Also, the default colour (which usually appears as black), isn't wdBlack but wdAuto.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 01-27-2016, 09:18 PM
joewoods joewoods is offline Macro to change all text color to black in all docx files in a selected folder Windows 7 64bit Macro to change all text color to black in all docx files in a selected folder Office 2007
Novice
Macro to change all text color to black in all docx files in a selected folder
 
Join Date: Jan 2016
Location: Chicago
Posts: 7
joewoods is on a distinguished road
Default

Thanks so much, Paul!! Sorry I posted it twice. I just tried it. It works, but not on the text in the header and footer. Is there a way to make it select that text as well?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to change all text color to black in all docx files in a selected folder Run a macro on multiple docx. files Peter Carter Word VBA 27 12-15-2022 04:10 PM
I can't change red text to black Nathan8752 Word 1 10-12-2015 08:26 AM
Macro to change all text color to black in all docx files in a selected folder macro to change name of files in a folder in order expert4knowledge Word VBA 5 07-10-2014 03:54 PM
Macro to change all text color to black in all docx files in a selected folder Word Macro - change date in footer for all files in a folder patidallas22 Word VBA 2 03-09-2012 08:14 AM
Change cell color everytime a value is selected in dropdown list angelica_gloria Excel 4 01-27-2012 06:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:25 PM.


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