I’m trying to work out if KM can work within Microsoft excel and word on my Apple iMac
I am frustrated that I cannot set up what I consider to be a simple macro within Microsoft Word
I have tried setting up a macro using Microsoft’s own macros to change the font within a document and have been unsuccessful
All I want to do is within a document to have any words that are in Cambria font to be identified and then change its colour to blue in the font size to 14
If I use the search and replace option within word I’m able to achieve this without a problem. However if I try to set up a macro, it does not work. All
This is what the macro looks like and is clearly incorrect and non-functional.
Sub Macro1()
’
’ Macro1 Macro
’
'
ActiveWindow.DocumentMapPercentWidth = 19
ActiveWindow.Panes(1).Activate
ActiveWindow.DocumentMap = True
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Can anyone please tell me if I can achieve this with KM
This simple Word VBA Macro works for me. Give it a test and let me know if it works for you.
One note: I found two fonts with the “Cambria” name in my Word 2011 setup:
“Cambria”
“Cambria (Theme Body)”
I had to take precautions to make sure my test text was using the first font.
###Word VBA Script
Sub Set_Format_Cambria_Text()
'
' Change ALL Text with "Cambria" font to:
' • Color: Blue
' • Size: 14
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
'--- SET FIND CRITERIA ---
With Selection.Find
.Text = ""
.Font.Name = "Cambria"
.Forward = True
.Wrap = wdFindContinue
.Format = True
'
'--- SET REPLACE CRITERIA ---
With .Replacement
.Text = ""
.Font.Color = wdColorBlue
.Font.Size = 14
End With
End With
'--- CHANGE ALL TEXT IN DOCUMENT ---
Selection.Find.Execute Replace:=wdReplaceAll
End Sub