I'm trying to create a macro to insert some text with custom formatting, then change the font style back to what it was before the macro was run. This is what I have come up with so far but it is giving me an error.
Dim myText As String
Dim oldFont As Object
'Save old font
Set oldFont = Selection.Font
'Insert text with custom font
myText = "CUSTOM STRING"
Selection.Font.Name = "Comic Sans MS"
Selection.Font.Size = 26
Selection.Font.Bold = True
Selection.TypeText (myText)
'Revert font back to original
Set Selection.Font = oldFont
Can anyone explain a way to do what I'm looking for? Thanks.
Edit: Sorry, I should have been more specific. If I am typing text, I have a certain formatting that I'm typing in that is shown on the Home Tab (eg. Comic Sans Ms, Size 22, Bold). When I insert text with the macro, this changes the formatting that I'm typing with, so if I continue typing it will be in the NEW font type, not the Comic Sans MS. I'm trying to make it so if I continue typing after I have inserted the text via macro, it will retain my old formatting.