Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Office > Outlook

LinkBack Thread Tools Display Modes
Old 03-31-2019, 07:47 AM
ghostwhisperer86 ghostwhisperer86 is offline Windows 10 Office 2016
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:
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
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

If Err <> 0 Then
MsgBox "Data on clipboard is not text."
End If

End Sub
Reply With Quote

Thread Tools
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to extract selected hyperlink address to clipboard? poetofpiano Word VBA 10 02-18-2018 07:17 PM
Macro to find text in between two characters and then format selected text? qcom Word 5 02-19-2015 11:23 PM
Copying Selected Text Between Word Documents Iluvatar343 Word VBA 1 06-05-2014 05:15 AM
Find & selected paras with highlighted text & copy to clipboard marceepoo Word VBA 1 09-14-2012 08:20 PM
Macro Delete Selected Text smonczka Word VBA 2 11-05-2011 03:18 AM

All times are GMT -7. The time now is 08:49 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc. is not affiliated with Microsoft