+ Reply to Thread
Results 1 to 7 of 7

excel to paste to word then attach word document to an email

  1. #1
    Registered User
    Join Date
    11-25-2016
    Location
    Warrington
    MS-Off Ver
    2010
    Posts
    60

    excel to paste to word then attach word document to an email

    Hi,

    Basically I'm trying to create a form in excel which can be filled in by the user, the content of the form isn't an issue and I am able to tell my macro to paste the excel data into a word document but now I want the same macro to attach the active word document to an email which I can then add body and subject too, again via the macro, I have previously been able to do an email macro but I cannot figure out how to combine them both, can anyone help, here is what I've got so far:

    Excel to word macro: (it currently saves it to my documents)
    Please Login or Register  to view this content.
    Then this one creates a blank email with the suvject and body that I want:
    Please Login or Register  to view this content.
    How do a smush these two together in one beautifully created macro?

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: excel to paste to word then attach word document to an email

    Try something along the lines of:
    Please Login or Register  to view this content.
    Note that, with the above code, the attachment is saved & sent as a PDF, which is then deleted from disk. You can retain it there by deleting:
    Kill strPath & "File_" & i & ".pdf"
    Last edited by macropod; 10-26-2017 at 05:58 AM.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    11-25-2016
    Location
    Warrington
    MS-Off Ver
    2010
    Posts
    60
    That great I'll get it tested when I'm back at my laptop on Monday lol, out of interest, if my excel document gas a header how do u tell the header to also move to the word document?
    Last edited by AliGW; 10-29-2017 at 07:08 AM. Reason: Unnecessary quotation removed.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: excel to paste to word then attach word document to an email

    Whatever you want to include in the document from the Excel workbook, you either have to copy & paste from there or insert via another method. On reviewing the code I posted, it seems a line got dropped out somewhere along the way. You should insert:
    Sheets("Template").Range("A1:F15").Copy
    immediately before or after:
    Set wdDoc = wdApp.Documents.Add()
    Given that you're already copying Row 1, I'd have thought that would include whatever 'header' data you want.

    PS: The code provides, too, for you to pass your i variable to it; it's nowhere specified in the code you posted, so I have no idea where you're getting it from.

  5. #5
    Registered User
    Join Date
    11-25-2016
    Location
    Warrington
    MS-Off Ver
    2010
    Posts
    60

    Re: excel to paste to word then attach word document to an email

    Quote Originally Posted by macropod View Post
    Whatever you want to include in the document from the Excel workbook, you either have to copy & paste from there or insert via another method. On reviewing the code I posted, it seems a line got dropped out somewhere along the way. You should insert:
    Sheets("Template").Range("A1:F15").Copy
    immediately before or after:
    Set wdDoc = wdApp.Documents.Add()
    Given that you're already copying Row 1, I'd have thought that would include whatever 'header' data you want.

    PS: The code provides, too, for you to pass your i variable to it; it's nowhere specified in the code you posted, so I have no idea where you're getting it from.
    Thanks, yeah I think I left my i variable in by mistake, I chopped it from some previous work I had done where the I stood for something lol

    I'll let you know how I get on, that's for your help!

  6. #6
    Registered User
    Join Date
    11-25-2016
    Location
    Warrington
    MS-Off Ver
    2010
    Posts
    60

    Re: excel to paste to word then attach word document to an email

    Hi Macropod,

    I appear to be getting an error at the

    Please Login or Register  to view this content.
    section, doesn't seem to want to progress past it and I keep getting a compile error, user defined type not defined.

    Do you know what could be causing this?

  7. #7
    Registered User
    Join Date
    11-25-2016
    Location
    Warrington
    MS-Off Ver
    2010
    Posts
    60

    Re: excel to paste to word then attach word document to an email

    Quote Originally Posted by ahalliwell View Post
    Hi Macropod,

    I appear to be getting an error at the

    Please Login or Register  to view this content.
    section, doesn't seem to want to progress past it and I keep getting a compile error, user defined type not defined.

    Do you know what could be causing this?
    ignore me

    I didn't reference outlook, doh!!

+ 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. Copy word document and Paste it as body of Email in Outlook (using VBA from Excel)
    By Asacras in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2017, 10:23 AM
  2. Paste Lotus Notes email body to Word Document
    By Yash20 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2016, 04:48 AM
  3. Call email and attach a word document
    By Ghostmonkey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-21-2016, 05:00 AM
  4. email data from excel or create a word document
    By terence17 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-14-2015, 12:32 PM
  5. Replies: 1
    Last Post: 12-02-2014, 06:13 AM
  6. How to convert Word document to PDF and attach to an email ...
    By lapot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2014, 05:06 PM
  7. Replies: 1
    Last Post: 01-06-2006, 06:35 PM

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