Results 1 to 4 of 4

Thread: Need Macro command to print and email a pdf file in Microsoft Excel

  1. #1
    Join Date
    Oct 2011
    Posts
    89

    Need Macro command to print and email a pdf file in Microsoft Excel

    I have a command button in my Excel spreadsheet where it will look at the email address typed into a specific field and email the excel file to that email address. What I want to do is when I push the button, first have the page print to a pdf, then send only the pdf file to the email address specified. How do I add this in the step of printing to a pdf.

  2. #2
    Join Date
    Oct 2011
    Posts
    80

    Re: Need Macro command to print and email a pdf file in Microsoft Excel

    You can use sendmail. Sample Code : Sub EnvoiMail () Workbooks ("UnClasseur"). SendMail Recipients: = "@ mailaddress", _ Subject: = "nameofworkbook", _ ReturnReceipt: = True End Sub. This macro sends, via the default browser, a mail recipient whose address is here email. The subject is indicated in Subject. You can put ReturnReceipt to True to request a return receipt (optional). Attached, the specified workbook that is sent to Sendmail. It could be the workbook containing the macro (ThisWorkbook), or the active workbook (ActiveWorkbook), etc.

  3. #3
    Join Date
    Jul 2011
    Posts
    440

    Re: Need Macro command to print and email a pdf file in Microsoft Excel

    I can provide you some reference threads that are already available on this forums. Read them, they will provide you more detail on working with macros with pdf files.
    Macro to convert file into PDF and then send via email
    I need a Macro in Excel by which I can send Email with Attachments
    Help with Macro for sending emails.

  4. #4
    Join Date
    Jul 2011
    Posts
    434

    Re: Need Macro command to print and email a pdf file in Microsoft Excel

    I use jawspdf creator. The software creates a PDF printer, it is sufficient to determine that it is the default printer. Or I have a code example which works with PDFCreator that you can see below.

    Code:
     Sub ToPDF () 
    
     Set pdfjob = CreateObject ("PDFCreator.clsPDFCreator") 
     NomExcel = ThisWorkbook.Name 
     NomPdf = Left (NomExcel, Len (NomExcel) - 4) & ". Pdf" 
     With pdfjob 
     If. Cstart ("/ NoProcessingAtStartup") = False Then 
     MsgBox "Can not initialize PDFCreator." VbCritical + vbOKOnly, "PrtPDFCreator" 
     Exit Sub 
     End If 
     . COption ("UseAutosave") = 1 
     . COption ("UseAutisaveDirectory") = 1 
     . COption ("AutosaveDirectory") = ThisWorkbook.Path 
     . COption ("AutosaveFilename") = NomPdf 
     . COption ("AutosaveFormat") = 0 
     . CClearCache 
     End With 
     ThisWorkbook.PrintOut copies: = 1, ActivePrinter: = "PDFCreator" 
     = 1 Do Until pdfjob.cCountOfPrintjobs 
     DoEvents 
     Loop 
     pdfjob.cPrinterStop = False 
     = 0 Do Until pdfjob.cCountOfPrintjobs 
     DoEvents 
     Loop 
     With pdfjob 
     . CDefaultprinter = DefaultPrinter 
     . CClearCache 
     . Cclose 
     End With 
     = Nothing Set pdfjob 
     End Sub

Similar Threads

  1. How to write Macro in Microsoft Excel 2010
    By Glinda in forum Tips & Tweaks
    Replies: 1
    Last Post: 06-06-2012, 04:28 PM
  2. How to rename from button with macro in Microsoft Excel
    By Kanshin in forum MS Office Support
    Replies: 16
    Last Post: 24-02-2012, 01:59 PM
  3. Replies: 5
    Last Post: 13-01-2012, 05:20 PM
  4. Replies: 2
    Last Post: 11-01-2012, 06:06 PM
  5. Macro to convert file into PDF and then send via email
    By MAGALY in forum Software Development
    Replies: 5
    Last Post: 09-12-2009, 05:00 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
  •  
Page generated in 1,713,437,032.87170 seconds with 17 queries