View Single Post
 
Old 03-31-2019, 07:47 AM
ghostwhisperer86 ghostwhisperer86 is offline Windows 10 Office 2016
Novice
 
Join Date: Mar 2019
Posts: 1
ghostwhisperer86 is on a distinguished road
Default 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
Reply With Quote