Macro for copying in clipboard more than one selected text
I'm making a VBA - Outlook macro but need to put in clipboard more than one selected text
ex: My open email is:
Hi,
this is the new article for commerce and name is Umbrella
if I the word "COMMERCE" and "UMBRELLA" and click on a macro button, they should put in a clipboard:
I have a vba code, but it takes only the word Umbrella.
Could you please help me?
Thanks so much
Public Sub CopyTextToClipBoard()
Dim objItem As Object
Dim objInsp As Outlook.Inspector
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim objSel As Word.Selection
Dim oData As MSForms.DataObject
Dim Word As Variant
Dim taken As Variant
Dim i As Integer
' Reference the current Outlook item
Set objItem = Application.ActiveInspector.CurrentItem
If Not objItem Is Nothing Then
If objItem.Class = olMail Then
Set objInsp = objItem.GetInspector
If objInsp.EditorType = olEditorWord Then
Set objDoc = objInsp.WordEditor
Set objWord = objDoc.Application
Set objSel = objWord.Selection
Set oData = New MSForms.DataObject
oData.SetText objSel.Text
oData.PutInClipboard
oData.GetFromClipboard
taken = oData.GetText
i = i + 1
MsgBox (taken)
End If
End If
End If
Set objItem = Nothing
Set objWord = Nothing
Set objSel = Nothing
Set objInsp = Nothing
NotText:
If Err <> 0 Then
MsgBox "Data on clipboard is not text."
End If
End Sub
|