vba paste

dspel79082

Board Regular
Joined
Sep 29, 2012
Messages
125
Hi All,

Hoping this is an easy question.(MS Office 2010) I am finishing up a mailing system with vb that is way too complicated to go into here. I have most all of my code finished and working except one bit that is causing me problems.
Excel creates my Outlook emails with addresses, attachments, etc. , but I have a need to paste one small bit of text into each email. I cannot use .body or .htmlbody in any form. It causes issues with my particular setup. I have to have an actual paste.

I have the data ready on the clipboard, and the Outlook mail as the active window with the cursor in position for the paste.
Can someone tell me how to paste at the cursor position of the active mail window? immediatley followed by my .send

I have tried many other ways to accomplish what I need, and I'd rather scrap this whole thing than deal with SendKeys and numlock bugs....

A couple of folks here on the message board have given some guidance, but none of the approaches have worked for me yet.
I just need a paste.



Hopefully someone here may know an easy way to accomplish this.

Thank you for your time.
Debbie
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Could you post a sample email? I am a bit curious why something like .body = body 1 & vbnewline & body 2 would not work
 
Upvote 0
Hi Dark, thank you for your time and interest. I really can't post the email as is it a company email. But basically my setup involves a very very elaborate automatically inserted Outlook signature, which includes images and hyperlinks, and .body or .htmlbody wipes out the images in my signature. For reasons that would be rather complicated to explain, the signature cannot be omitted or altered or entered in any other manner than the auto entry by Outlook. So in order to add the bit of text without messing up the signature, I need a paste.

Thanks again,
Debbie
 
Upvote 0
As far as I am aware, in order to paste into Outlook as you're describing you need to use the WordEditor property. You'll probably find that this generates an Outlook security warning, although if you ran this (or your whole code from Outlook you'd avoid this).

Anyway, try amalgamating this code with your own

(Excel)
Code:
Sub PasteImage()

    Dim outApp As Outlook.Application
    Dim outMail As Outlook.MailItem
    Dim wdDoc As Word.Document
    
    Set outApp = Outlook.Application
    Set outMail = outApp.ActiveInspector.CurrentItem
    Set wdDoc = outApp.ActiveInspector.WordEditor
    
    wdDoc.Application.Selection.Paste


    Set wdDoc = Nothing
    Set outMail = Nothing
    Set outApp = Nothing
    
End Sub

(Outlook)
Code:
Sub PasteImage()

    Dim outMail As Outlook.MailItem
    Dim wdDoc As Word.Document
    
    Set outMail = Application.ActiveInspector.CurrentItem
    Set wdDoc = Application.ActiveInspector.WordEditor
    
    wdDoc.Application.Selection.Paste


    Set wdDoc = Nothing
    Set outMail = Nothing
    
End Sub

Hope this is of some help

Simon
 
Last edited:
Upvote 0
Hi Simon, I am just now getting back to the forums for the first time since you answered my post, and I want to let you know that your answer was spot on. My system is finished, and working like magic. Thank so much for your help.

Thank you very much,
Debbie
 
Upvote 0

Forum statistics

Threads
1,216,064
Messages
6,128,562
Members
449,458
Latest member
gillmit

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top