Using Clipboad in Outlook VBA

M

Michael

Hello to all

I using XP and Outlook 2003 and I like to copy selected mailadresses from
the current OL Explorer (contact items) to the clipboard. Problem: The
clipboad Object doesn't work. I don't know why.

Thank you for any hint!

Michael

Public Sub A_Mail2Clipboard()
'This Makro shall copy all emailaddresses from selected records of the
current OL Explorer

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim MsgTxt As String
Dim x As Integer
MsgTxt = ""
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
MsgTxt = MsgTxt & myOlSel.Item(x).Email1Address & ", "
Next x



clipboard.SetText MsgTxt '<-------- It looks like, the
clipboard is not available ?????


End Sub
 
M

Michael

Hi again.

Here are my final code: Maybe someone can use it too.

Thanks to all!

Michael



Dim MyData As DataObject

Public Sub A_Mail2Clipboard()
'This Makro copies all emailaddresses from selected records of the
current OL explorer

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim MsgTxt As String
Dim x As Integer
MsgTxt = ""
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
MsgTxt = MsgTxt & myOlSel.Item(x).Email1Address & ", "
Next x


Set MyData = New DataObject

MyData.SetText MsgTxt

MyData.PutInClipboard


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top