Cubajz
05-12-2017, 02:40 AM
Hi guys:),
I have this macro function for simple batch replacement using Graham Mayor :clap:awesome:clap: plugin. It works really well, however I was wondering: Would it be possible to change the macro, so that .Text = "test" 'word to find would be actualy "Clipboard Content", in other words that this macro would use clipboard content as text to find, something like: .Text = Clipboard content. I am newbie so sry for my uniteligent writings :doh:Thanks for any help in advance: pray2:, code is below:
Function Replace007(oDoc As Document) As Boolean
Dim oRng As Range
On Error GoTo err_handler
Set oRng = oDoc.Range
With oRng.Find
.Text = "test" 'word to find
.MatchWholeWord = True
.MatchCase = True
.Font.Italic = True
.Font.Color = wdColorRed
With .Replacement
.Text = "test" 'replacement word
.Font.Italic = False
.Font.Bold = True
.Font.Color = wdColorAutomatic
End With
.Execute Replace:=wdReplaceAll
End With
'Repeat as required e.g.,
'Set oRng = oDoc.Range
'...
Set oRng = oDoc.Range
With oRng.Find
.Text = "mouse" 'word to find
.MatchWholeWord = True
.MatchCase = True
.Font.Bold = True
.Font.Color = wdColorAutomatic
With .Replacement
.Text = "lion" 'replacement word
.Font.Italic = True
.Font.Bold = False
.Font.Color = wdColorBlue
End With
.Execute Replace:=wdReplaceAll
End With
Replace007 = True
lbl_Exit:
Exit Function
err_handler:
Replace007 = False
Resume lbl_Exit
End Function
I have this macro function for simple batch replacement using Graham Mayor :clap:awesome:clap: plugin. It works really well, however I was wondering: Would it be possible to change the macro, so that .Text = "test" 'word to find would be actualy "Clipboard Content", in other words that this macro would use clipboard content as text to find, something like: .Text = Clipboard content. I am newbie so sry for my uniteligent writings :doh:Thanks for any help in advance: pray2:, code is below:
Function Replace007(oDoc As Document) As Boolean
Dim oRng As Range
On Error GoTo err_handler
Set oRng = oDoc.Range
With oRng.Find
.Text = "test" 'word to find
.MatchWholeWord = True
.MatchCase = True
.Font.Italic = True
.Font.Color = wdColorRed
With .Replacement
.Text = "test" 'replacement word
.Font.Italic = False
.Font.Bold = True
.Font.Color = wdColorAutomatic
End With
.Execute Replace:=wdReplaceAll
End With
'Repeat as required e.g.,
'Set oRng = oDoc.Range
'...
Set oRng = oDoc.Range
With oRng.Find
.Text = "mouse" 'word to find
.MatchWholeWord = True
.MatchCase = True
.Font.Bold = True
.Font.Color = wdColorAutomatic
With .Replacement
.Text = "lion" 'replacement word
.Font.Italic = True
.Font.Bold = False
.Font.Color = wdColorBlue
End With
.Execute Replace:=wdReplaceAll
End With
Replace007 = True
lbl_Exit:
Exit Function
err_handler:
Replace007 = False
Resume lbl_Exit
End Function