VBA to Change Clipboard Text Color to Red and Paste Text to Word

chasoe

Board Regular
Joined
Jan 29, 2006
Messages
73
Dear Sirs,

As I need to repetitively coping text strings from PDF and then paste to specific locations in Word document but in red font color.

I'm thinking of creating a macro to change the text color in the Clipboard to red first, and then paste them to Word.
ie
1. Select text string from PDF, Ctrl + C (to copy to Clipboard)
2. Go to Word document, excute the macro for pasting

Grateful if someone could help.

Many thanks.

Edward
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You can't manipulate text like that in the clipboard. Changes like that have to be done either before you copy or after you paste.
 
Upvote 0
You can't manipulate text like that in the clipboard. Changes like that have to be done either before you copy or after you paste.
Thanks for your advice, and I've thought out a work around which I would like to share :
(macro will create a new temp Word document, paste the string, select all to change to font color, and copy to required Word in desired place, the temp document will be closed without saving)

Code:
Sub PasteSelectionInRed

Dim docA As String
Dim docB As String
Application.ScreenUpdating = False

docA = ActiveDocument.Name
Documents.Add Template:=docB, NewTemplate:=True

docB = ActiveDocument.Name
Selection.PasteSpecial DataType:=wdPasteText

Selection.WholeStory
With Selection.Font
.Name = "Times New Roman"
.Size = 12
.Color = vbRed
End With
Selection.Copy

Documents(docA).Activate
Selection.Paste

Documents(docB).Close SaveChanges:=wdDoNotSaveChanges

Set tmpName = Nothing

Application.ScreenUpdating = True

End Sub

The above codes will be stored in Work's template, with the macro icon stick to the ribbon bar.
When cut is done in PDF, then place cursor to Word document at desired location, and click the macro icon in ribbon, and everything is done.
This macro will save the work of selecting the pasted string in Word and change font color, which will become very tedious if done repeatedly.

Rgds,
Edward
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,044
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top