Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-06-2017, 01:48 PM
macropod's Avatar
macropod macropod is offline Replace font size with macro Windows 7 64bit Replace font size with macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,512
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

For whatever reason, the macro recorder doesn't capture the font name for either the Find or the Replace. Hence a recorded macro will affect content other than just Times New Roman. Regardless, a macro this limited wouldn't make it any easier to "handle more than 100 files" as specified in post #1. For that, you'd need something like:


Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  If strFolder & "\" & strFile <> strDocNm Then
    Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
    With wdDoc
      With .Range.Find
        .ClearFormatting
        .Text = ""
        .Font.Name = "Times New Roman"
        .Font.Size = 12
        With .Replacement
          .ClearFormatting
          .Text = ""
          .Font.Size = 8
        End With
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute Replace:=wdReplaceAll
      End With
      .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
The above code includes a folder browser and will update all files in the selected folder.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Font size showing different (some superscripted??) but tools show its the same size? mikkygee PowerPoint 4 12-14-2015 11:21 PM
Replace font size with macro Looping Macro to Change Font, Font Size, and Give Heading 1 WH7262 Word VBA 1 08-26-2014 03:46 PM
Replace font size with macro Character based Search and Replace font size anacond11 Word 2 08-08-2013 08:10 AM
Replace font size with macro MAcro to List all the Font & its size in a word document shaukat74 Word VBA 1 01-29-2013 09:34 PM
Replace font size with macro how change size font to inches size kkepo Word 4 08-28-2012 08:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:44 AM.


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