#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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 |
|
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 |
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 |