PDA

View Full Version : Copy text then paste with a different format



Bernadette
08-17-2012, 10:13 AM
Hello VBA Express Forum! You have been most helpful to me in the past and I am in need of assistance again.

After I have copied some text I would like a macro to:

Type a note: (moved from para. ?) in green font colour and bold
Paste the copied text with the font colour changed to redExample:

(moved from para. ?) On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document.

The macro that I have works but I have to select the text that I have pasted before running the macro.

Sub Redline_Annotation()
'
' Makes selected text red then moves insertion point to beginning of selected text and inserts the annotation
'
Selection.Font.Color = wdColorRed
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.Font.Color = 5287936
Selection.Font.Bold = True
Selection.TypeText Text:="(moved from para. ?) "
'
End Sub

Any help would be much appreciated!

Thank you, Bernie

Bernadette
08-17-2012, 10:51 AM
I figured it out myself. Not sure if this is "proper" code but it does what I want:

Selection.Font.Bold = True
Selection.Font.Color = 5287936
Selection.TypeText Text:="(moved from para. ?) "
Selection.Font.Bold = False
Selection.TypeText Text:=" "
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Font.Color = wdColorRed
Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)

I would still like to know how to get the "Smart Options" smart tag to appear after the paste though.