+ Reply to Thread
Results 1 to 5 of 5

VBA Code Not Pasting data in Outlook from Excel. Only CTRL V works

  1. #1
    Registered User
    Join Date
    10-26-2022
    Location
    Puerto Rico
    MS-Off Ver
    Office 365
    Posts
    3

    VBA Code Not Pasting data in Outlook from Excel. Only CTRL V works

    Greetings:

    Attached is the code I have to copy data from an active excel spreadsheet. When run it opens the new email, fill the TO, CC and Subject fields, also change the delivery delay info. But the data in the email body only shows if I hit CTRL V.

    Any assistance its kindly welcome.

    Private Sub CommandButton1_Click()

    Dim a As Integer
    Dim objOutlook As Object
    Dim objMail As Object
    Dim rngTo As Range
    Dim rngCC As Range
    Dim rngSubject As Range
    Dim rngBody As Range
    Dim rngAttach As Range

    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItem(0)

    a = ActiveCell.Row

    With ActiveSheet

    Set rngTo = Range("B3")
    Set rngCC = Range("B5")
    Set rngSubject = .Range("B12")
    Set rngBody = .Range("A14:B32")
    rngBody.Copy

    End With

    With objMail

    .to = rngTo.Value
    .CC = rngCC.Value
    .Subject = rngSubject.Value
    'SET DELAY DELIVERY DATE - Stay in the outbox untill this date and time
    .DeferredDeliveryTime = "11/10/2022 11:00:00 AM"
    rngBody.PasteSpecial
    'Instead of .Display, you can use .Send to send the email or .Save to save a copy in the drafts folder
    .Display

    End With

    Set objOutlook = Nothing
    Set objMail = Nothing
    Set rngTo = Nothing
    Set rngCC = Nothing
    Set rngSubject = Nothing
    Set rngBody = Nothing
    Set rngAttach = Nothing

    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: VBA Code Not Pasting data in Outlook from Excel. Only CTRL V works

    Look at the code in the attached sample workbook.

    You should be able to make it work for you.

    There is also a bigger sample here.

    https://www.excelforum.com/excel-pro...o-outlook.html



    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    10-26-2022
    Location
    Puerto Rico
    MS-Off Ver
    Office 365
    Posts
    3

    Re: VBA Code Not Pasting data in Outlook from Excel. Only CTRL V works

    Thanks Davesexcel:

    I have a question? Why do I have to used ctrl v when I expect an automatic paste on this part of the code?

    Set rngTo = Range("B3")
    Set rngCC = Range("B5")
    Set rngSubject = .Range("B12")
    Set rngBody = .Range("A14:B32")
    rngBody.Copy


    End With

    With objMail

    .to = rngTo.Value
    .CC = rngCC.Value
    .Subject = rngSubject.Value
    'SET DELAY DELIVERY DATE - Stay in the outbox untill this date and time
    .DeferredDeliveryTime = "11/10/2022 11:00:00 AM"
    rngBody.PasteSpecial
    'Instead of .Display, you can use .Send to send the email or .Save to save a copy in the drafts folder
    .Display

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: VBA Code Not Pasting data in Outlook from Excel. Only CTRL V works

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Doesn't mean anything.


    Follow the samples I supplied.

  5. #5
    Registered User
    Join Date
    10-26-2022
    Location
    Puerto Rico
    MS-Off Ver
    Office 365
    Posts
    3

    Re: VBA Code Not Pasting data in Outlook from Excel. Only CTRL V works

    Thanks Davesexcel:

    I custom the code provided by you. It does WORK.

    Kindly Appreciated!!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Code only works in debug, skips pasting when run on its own
    By KTam169 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-24-2020, 11:03 PM
  2. Replies: 6
    Last Post: 10-26-2015, 05:51 AM
  3. [SOLVED] CTRL+C & CTRL+V copy single but pasting tab delimited spaced
    By Jack7774 in forum Excel General
    Replies: 4
    Last Post: 03-20-2015, 08:23 AM
  4. Code works for outlook 2010 but not 2013
    By Legend Rubber in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2015, 05:00 PM
  5. Replies: 1
    Last Post: 12-20-2014, 03:36 AM
  6. VBA Code works with step (f8) not run <ctrl>f8
    By rmacia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2013, 02:26 PM
  7. Ctrl find, copy and pasting help please (Macro code needed)
    By leanne2011 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-28-2011, 10:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1