Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2018, 08:55 AM
namedujour
Guest
 
Posts: n/a
Default Macro that swaps out font type

I'm trying to create a macro that searches for a specific font, and replaces it with another font. I've recorded Select All on the document, then performed a CTRL+H Replace All function, and went through the steps. When I try to run the macro, it doesn't do anything. I've tried this a couple of times and can't get it to work.



Is this just something that Word cannot do? Is there a function somewhere that I can dig up and use to perform this task? Please let me know. Thanks!

Last edited by Charles Kenyon; 08-02-2018 at 05:26 AM. Reason: Mark as solved
Reply With Quote
  #2  
Old 08-01-2018, 09:51 AM
Charles Kenyon Charles Kenyon is offline Macro that swaps out font type Windows 10 Macro that swaps out font type Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,138
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

You do not need the Select All.


You really should be using styles for your formatting. You would find it a lot simpler.


The recorder does not handle everything, by any means.


This should get you started:


Code:
Sub Macro1()
'
' Macro1 Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ""
        .Font.Name = "Garamond"
        .Replacement.Text = ""
        .Replacement.Font.Name = "Arial Narrow"
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Last edited by Charles Kenyon; 08-02-2018 at 05:26 AM.
Reply With Quote
  #3  
Old 08-01-2018, 12:51 PM
namedujour
Guest
 
Posts: n/a
Default

I do use styles for formatting. But I work for a company that programmed its own custom font and required it as part of its branding, and didn't do it very well. The font is buggy. It doesn't hold onto its attributes, which dynamically change in size, spacing, and indentation, so when you're developing content you spend 50% of your time resetting the style attributes. So you fix it for now, then when you reopen the file, it's all messed up again.

My solution is to develop content in Verdana, and replace it with the bogus font at the last minute before I save it to a pdf, and before it can morph into something I don't want.

I'll try the code and see if it works. Thanks
Reply With Quote
  #4  
Old 08-01-2018, 01:27 PM
namedujour
Guest
 
Posts: n/a
Default

I tried the macro, and it didn't work, so I did some research and found that the code needs to spell out "Name" in order for it to work. I put the change below. Thanks for your help!


Sub Macro1()
'
' Macro1 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Font.Name = "Garamond"
.Replacement.Text = ""
.Replacement.Font.Name = "Arial Narrow"
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Font Type changes with change in language animex Word 1 09-08-2017 05:23 PM
Macro that swaps out font type Type 1 font d4okeefe Word 3 02-09-2016 01:16 AM
Mysterious Font Type Symbol curiousUser Word 2 08-18-2014 05:10 AM
Changing default font size and type p_segura_es PowerPoint 2 01-28-2013 12:48 AM
Can't change font type or size sideways Word 2 11-01-2009 09:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft