Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 06-21-2017, 01:32 AM
Artmax Artmax is offline Batch replace Header and Footer and QuickStyle Windows 10 Batch replace Header and Footer and QuickStyle Office 2016
Novice
Batch replace Header and Footer and QuickStyle
 
Join Date: Jun 2017
Posts: 7
Artmax is on a distinguished road
Default

Okay, So I have tried to develop a script for finding text in a particular font ("Segoe Script") and then updating that text to a Style (which has Arial font... but I wanted the option to change the styles in the future hense not a straight font change)
It's based on a macro record for the search - this proved unhelpful as I don't know how it selects or activates.

It runs without error but doesn't do anything.

Code:
Function FontStyle(oDoc As Document) As Boolean
Dim oSection As Section
    On Error GoTo Err_Handler
    'Do Something with oDoc here. e.g.,"
           oDoc.Range.Find.ClearFormatting
            With Range.Find
                .Text = ""
                .Font.Name = "Segoe Script"
                .Replacement.Text = ""
                .Replacement.Style = ActiveDocument.Styles("AsideStyle")
                .Forward = True
                .Wrap = wdFindContinue
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
                .Excecute Replace:=wdReplaceAll
            End With
        
    FontStyle = True 
lbl_Exit:
    Exit Function
Err_Handler:
    FontStyle = False 
    Err.Clear
    GoTo lbl_Exit
End Function
FYI This is the code which is created in the recorded Macro - Doesn't seem to even select the font in the recording.

Code:
Sub font()
'
' font Macro
'
'
Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Style = ActiveDocument.Styles("ASideStyle")
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
I've looked over so many other things to make a selection, but can't get anything to work. Any ideas?

:/
Reply With Quote
 

Tags
macro find and replace, styles, word 2016



Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch replace Header and Footer and QuickStyle Find & Replace in Header/Footer in 1000 files amodiammmuneerk@glenmarkp Word 12 03-05-2018 03:31 AM
Batch replace Header and Footer and QuickStyle New to VBA - Find/Replace in MS Word 2010 that Searches Header/Footer mbreggs Word VBA 4 06-01-2016 08:02 AM
Batch replace Header and Footer and QuickStyle Find/replace font colour in all header/footer trillium Word VBA 4 10-20-2015 10:39 PM
Batch replace Header and Footer and QuickStyle Created VBA to Find and Replace in Body, Header and Footer with Highlighting the replacement text QA_Compliance_Advisor Word VBA 11 09-23-2014 04:40 AM
Batch replace Header and Footer and QuickStyle Find & Replace in Header/Footer PReinie Word 6 01-22-2014 06:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:51 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