Results 1 to 4 of 4

Copy and Paste table into Email - Adding lines before table

Threaded View

  1. #1
    Registered User
    Join Date
    02-19-2024
    Location
    Atlants, GA
    MS-Off Ver
    Excel 365
    Posts
    4

    Copy and Paste table into Email - Adding lines before table

    I have a script to copy a table into an email and want to have a couple lines before the table. I have tried several different methods but when it pastes the table it pastes it at the very beginning. Thank you for your help.

    Sub copy_email()
    '
    ' copy_email Macro
    ' Keyboard Shortcut: Ctrl+e
    
    
    Dim OutApp As Object
    Dim OutMail As Object
    Dim table As Range
    Dim pic As Picture
    Dim ws As Worksheet
    Dim wordDoc
    
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    
    Dim rng As Range
    Set ws = ThisWorkbook.Sheets("Sheet1")
    Set rng = ws.Range("A1:I27")
    
    With OutMail
        .To = "to"
        .Subject = "test"
        .Display
        .HTMLBody = "test test"
        Dim wdDoc As Object     '## Word.Document
        Dim wdRange As Object   '## Word.Range
        Set wdDoc = OutMail.GetInspector.WordEditor
        Set wdRange = wdDoc.Range(0, 0)
        wdRange.InsertAfter vbCrLf & vbCrLf
        
        'Copy the range in-place
        rng.Copy
        wdRange.Paste
    End With
        On Error GoTo 0
        
        Range("A1").Select
        
    Set OutApp = Nothing
    Set OutMail = Nothing
    
    End Sub
    Attached Files Attached Files
    Last edited by AliGW; 04-20-2024 at 12:21 PM. Reason: Code tags added - please review the forum guidelines.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Formulas in Table change when adding new lines
    By Rchuno in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-05-2023, 12:09 AM
  2. Replies: 1
    Last Post: 05-11-2021, 04:58 PM
  3. Macro to copy and paste lines from table in invoice and print
    By IsabelleArtMas in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-21-2021, 05:47 AM
  4. Pull data from table in email into lines in excel
    By mgolightly in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2017, 05:30 PM
  5. Copy visible cells in filtered table and paste in userform textbox - email
    By pfeifferjoey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2014, 11:23 AM
  6. Macro to Copy Pivot Table and Paste a Regular Data Table in the Same Position
    By webfeet2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2013, 06:34 AM
  7. Copy paste a table in outlook email to excel
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-16-2012, 04:41 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