+ Reply to Thread
Results 1 to 3 of 3

convert to pdf and then mail, using existing vba

Hybrid View

  1. #1
    Registered User
    Join Date
    02-20-2014
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    36

    convert to pdf and then mail, using existing vba

    Hi,
    With lots of copy-paste, I finally have a system to e-mail an excel file. This is done using various sources, and now looks like this (I removed the lines which I think to be irrelevant) :

    Sub reply_general()
    Dim olApp As Object
    Dim olMail As Object
    Dim answer As String
    Dim agree As String
    Dim BodyCode As String
    Dim str_tmppath
    
    
    str_tmppath = Environ("temp") & "\Verlofaanvraagreply.xlsm"
    
    
    ActiveWorkbook.SaveCopyAs Filename:=str_tmppath
    I understand that the way of working with the str_tmppath has the advantage that Outlook can easily find the file to attach :

    .Attachments.Add str_tmppath
    I now would modify this in such a way that I send the file as a PDF file. How should I modify the codes ? I assume that I have to replace the last line in the first block.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,746

    Re: convert to pdf and then mail, using existing vba

    There is a little more to it than just replacing one line. You have to first save the file as a PDF file, then attach the PDF file. This example just outputs the active sheet. You need more complexity if you want more sheets to go to one PDF file.

    Sub reply_general()
    Dim olApp As Object
    Dim olMail As Object
    Dim answer As String
    Dim agree As String
    Dim BodyCode As String
    Dim str_tmppath As String
    Dim PDFpath As String
    
    
    str_tmppath = Environ("temp") & "\Verlofaanvraagreply.xlsm"
    PDFpath = Environ("temp") & "\Verlofaanvraagreply"
    
    ActiveWorkbook.SaveCopyAs Filename:=str_tmppath
    
       ActiveSheet.ExportAsFixedFormat _
          Type:=xlTypePDF, _
          Filename:=PDFpath, _
          Quality:=xlQualityStandard, _
          IncludeDocProperties:=True, _
          IgnorePrintAreas:=False, _
          OpenAfterPublish:=False
    
    ...
    
    .Attachments.Add PDFpath
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-20-2014
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: convert to pdf and then mail, using existing vba

    Thanks a lot, I appreciate !

+ 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. Display,mail record in existing user form
    By saba@thejaingroup.co in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2017, 03:10 PM
  2. Display,mail record in existing user form
    By saba@thejaingroup.co in forum Excel General
    Replies: 0
    Last Post: 01-01-2017, 03:57 PM
  3. From Excel macro, Open (but do not run) an existing Mail Merge Doc
    By vh_llc@yahoo.com in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-11-2014, 07:42 AM
  4. [SOLVED] Convert to PDF and E-mail
    By superdonk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 06:41 AM
  5. Open Outlook / send existing mail
    By koltregaskes in forum Excel General
    Replies: 1
    Last Post: 05-28-2012, 04:47 AM
  6. Open and send an existing mail via an Excel macro
    By koltregaskes in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2011, 08:42 AM
  7. Macro: Convert to PDF & E-mail. Possible?
    By wilro85 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-30-2006, 12:50 PM

Tags for this Thread

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