VBA code to convert excel to pdf and email it as attachment

aarondesin91

New Member
Joined
Jun 23, 2013
Messages
7
Dear Forumers,

I really need your help. I am new to this whole VBA coding thing have no basic at all in programming and stuff so please help me out here. I am currently assigned a project where I have to create a excel sheet which act as a templete for sending request. The requirement of the project is that I need a vba code for a button when i click it, it will convert my active sheet alone to pdf, automatically save it with the title captured from a cell in the active sheet which is entered by the user. Email this pdf as a attachment to the specific person. Please help me out, my job depends on this project please guys out there.

Thank you
 
Do you mean all sheets should be in the attached PDF file or only some of them?
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
The below code sends Sheet1 and Sheet3 in the attached single PDF file.
Those sheets are listed in MySheets constant in the top of the code, modify it as required.
To send all sheets use Const MySheets As Variant = 0
Signature is added to the bottom of email.
Code:
[COLOR=darkblue]Sub[/COLOR] Attach_Sheets_As_Pdf_With_Signature()
[COLOR=green]' ZVI:2016-09-20 http://www.mrexcel.com/forum/excel-questions/710212-visual-basic-applications-code-convert-excel-pdf-email-attachment-5.html#post4636652[/COLOR]
 
  [COLOR=green]' --> User settings, change to suit[/COLOR]
  [COLOR=darkblue]Const[/COLOR] MySheets [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR] = "Sheet1,Sheet3" [COLOR=green]' Use MySheets = 0 for all the sheets[/COLOR]
  [COLOR=darkblue]Const[/COLOR] IsDisplay [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Boolean[/COLOR] = [COLOR=darkblue]True[/COLOR]           [COLOR=green]' Change to False to .Send instead of .Display[/COLOR]
  [COLOR=darkblue]Const[/COLOR] IsSilent [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Boolean[/COLOR] = [COLOR=darkblue]False[/COLOR]           [COLOR=green]' Change to True to Send without the confirmation MsgBox[/COLOR]
  [COLOR=green]' <-- End of settings[/COLOR]
 
  [COLOR=darkblue]Dim[/COLOR] IsCreated [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Boolean[/COLOR]
  [COLOR=darkblue]Dim[/COLOR] PdfFile [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR], Signature [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
  [COLOR=darkblue]Dim[/COLOR] OutlApp [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Object[/COLOR]
  [COLOR=darkblue]Dim[/COLOR] i [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
  [COLOR=darkblue]Dim[/COLOR] char [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR]
 
  [COLOR=green]' Define PDF filename[/COLOR]
  PdfFile = ActiveWorkbook.Name
  i = InStrRev(PdfFile, ".xl", , vbTextCompare)
  [COLOR=darkblue]If[/COLOR] i > Len(PdfFile) - 5 [COLOR=darkblue]Then[/COLOR] PdfFile = Left(PdfFile, i - 1)
  PdfFile = PdfFile & "_" & ActiveSheet.Name
  [COLOR=green]' Clean up the name of PDF file[/COLOR]
  [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] char [COLOR=darkblue]In[/COLOR] Split("? "" / \ < > * | :")
    PdfFile = Replace(PdfFile, char, "_")
  [COLOR=darkblue]Next[/COLOR]
  [COLOR=green]' Add %TEMP% path to the file name and limit too long name[/COLOR]
  PdfFile = Left(CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) & "\" & PdfFile, 251) & ".pdf"
 
  [COLOR=green]' Try to delete PDF file for the case it was not deleted at debugging[/COLOR]
  [COLOR=darkblue]If[/COLOR] Len(Dir(PdfFile)) [COLOR=darkblue]Then[/COLOR] Kill PdfFile
 
  [COLOR=green]' Select sheets to be exported in the PDF (single) file[/COLOR]
  [COLOR=darkblue]If[/COLOR] MySheets = 0 [COLOR=darkblue]Then[/COLOR]
    [COLOR=green]' All sheets to PDF[/COLOR]
    Sheets.Select
  [COLOR=darkblue]Else[/COLOR]
    [COLOR=green]' Sheets listed in MySheets to PDF[/COLOR]
    Sheets(Split(MySheets, ",")).Select
  [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
 
  [COLOR=green]' Export the selected sheets as PDF to the temporary folder[/COLOR]
  [COLOR=darkblue]With[/COLOR] ActiveSheet
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    .Select
  [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
 
  [COLOR=green]' Use the already open Outlook if possible[/COLOR]
  [COLOR=darkblue]On[/COLOR] [COLOR=darkblue]Error[/COLOR] [COLOR=darkblue]Resume[/COLOR] [COLOR=darkblue]Next[/COLOR]
  Set OutlApp = GetObject(, "Outlook.Application")
  [COLOR=darkblue]If[/COLOR] Err [COLOR=darkblue]Then[/COLOR]
    Set OutlApp = CreateObject("Outlook.Application")
    IsCreated = [COLOR=darkblue]True[/COLOR]
  [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
  [COLOR=darkblue]On[/COLOR] [COLOR=darkblue]Error[/COLOR] [COLOR=darkblue]GoTo[/COLOR] 0
 
  [COLOR=green]' Prepare email with PDF attachment and default signature[/COLOR]
  [COLOR=darkblue]With[/COLOR] OutlApp.CreateItem(0)
   
    [COLOR=green]' Add the attachment first for correct attachment's name with non English symbols[/COLOR]
    .Attachments.Add PdfFile
   
    [COLOR=green]' Get default email signature without blinking (instead of .Display method)[/COLOR]
    [COLOR=darkblue]With[/COLOR] .GetInspector: [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
    Signature = .Body
 
    [COLOR=green]' Prepare e-mail (uncommenmt and fill the lines below)[/COLOR]
    .Subject = "Payroll Monthly Analysis"
    .To = Range("L3").Value
    .CC = Range("L4").Value
    .Body = "Hi," & vbLf & vbLf _
          & "Please find the latest payroll report attached" & vbLf & vbLf _
          & Signature
   
    [COLOR=green]' Try to send or just display the e-mail[/COLOR]
    [COLOR=darkblue]On[/COLOR] [COLOR=darkblue]Error[/COLOR] [COLOR=darkblue]Resume[/COLOR] [COLOR=darkblue]Next[/COLOR]
    [COLOR=darkblue]If[/COLOR] IsDisplay [COLOR=darkblue]Then[/COLOR] .Display [COLOR=darkblue]Else[/COLOR] .Send
   
    [COLOR=green]' Show error of .Send method[/COLOR]
    [COLOR=darkblue]If[/COLOR] [COLOR=darkblue]Not[/COLOR] IsDisplay [COLOR=darkblue]Then[/COLOR]
      [COLOR=green]' Return focus to Excel's window[/COLOR]
      Application.Visible = [COLOR=darkblue]True[/COLOR]
      [COLOR=green]' Report on error or success[/COLOR]
      [COLOR=darkblue]If[/COLOR] Err [COLOR=darkblue]Then[/COLOR]
        MsgBox "E-mail was not sent for some reasons" & vbLf & "Please check it", vbExclamation
        .Display
      [COLOR=darkblue]Else[/COLOR]
        [COLOR=darkblue]If[/COLOR] [COLOR=darkblue]Not[/COLOR] IsSilent [COLOR=darkblue]Then[/COLOR]
          MsgBox "E-mail successfully sent", vbInformation
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
      [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]On[/COLOR] [COLOR=darkblue]Error[/COLOR] [COLOR=darkblue]GoTo[/COLOR] 0
 
  [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]With[/COLOR]
 
  [COLOR=green]' Delete the temporary PDF file[/COLOR]
  [COLOR=darkblue]If[/COLOR] Len(Dir(PdfFile)) [COLOR=darkblue]Then[/COLOR] Kill PdfFile
 
  [COLOR=green]' Try to quit Outlook if it was not previously open[/COLOR]
  [COLOR=darkblue]If[/COLOR] IsCreated [COLOR=darkblue]Then[/COLOR] OutlApp.Quit
 
  [COLOR=green]' Try to release the memory of object variable[/COLOR]%
 
Last edited:
Upvote 0
Hi ZVI,

Awesome thread , there are so many pages on here so i was hoping you could help me and advise which one suits best for my situation...

I am using excel 2013

I want to be able to email certain sheets as PDF but not the whole range
I have sheets called Dashboard and WeeklyInput
I want to be able to export range A1 to X500 as PDF from the dashboard sheet and range A1:D200 to export from sheet weekly
I want to then SetPrint are to these ranges and then print them also..

The PDF file should be titled Summary for and what the previous date was

My sheets have shapes and charts therefore i would want it to look exactly the same as it looks onmy excel sheets but as PDF file

Hopefully you can help me tweak your existing code to achieve this..

Many Thanks
 
Last edited:
Upvote 0
The below code sends Sheet1 and Sheet3 in the attached single PDF file.
Those sheets are listed in MySheets constant in the top of the code, modify it as required.
To send all sheets use Const MySheets As Variant = 0
Signature is added to the bottom of email.
I repost the code here:
Rich (BB code):
Sub Attach_Sheets_As_Pdf_With_Signature()
' ZVI:2016-09-20 http://www.mrexcel.com/forum/excel-questions/710212-visual-basic-applications-code-convert-excel-pdf-email-attachment-5.html#post4636678
 
  ' --> User settings, change to suit
  Const MySheets As Variant = "Sheet1,Sheet3" ' Use MySheets = 0 for all the sheets
  Const IsDisplay As Boolean = True           ' Change to False to .Send instead of .Display
  Const IsSilent As Boolean = False           ' Change to True to Send without the confirmation MsgBox
  ' <-- End of settings
 
  Dim IsCreated As Boolean
  Dim PdfFile As String, Signature As String
  Dim OutlApp As Object
  Dim i As Long
  Dim char As Variant
 
  ' Define PDF filename
  PdfFile = ActiveWorkbook.Name
  i = InStrRev(PdfFile, ".xl", , vbTextCompare)
  If i > Len(PdfFile) - 5 Then PdfFile = Left(PdfFile, i - 1)
  PdfFile = PdfFile & "_" & ActiveSheet.Name
  ' Clean up the name of PDF file
  For Each char In Split("? "" / \ < > * | :")
    PdfFile = Replace(PdfFile, char, "_")
  Next
  ' Add %TEMP% path to the file name and limit too long name
  PdfFile = Left(CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) & "\" & PdfFile, 251) & ".pdf"
 
  ' Try to delete PDF file for the case it was not deleted at debugging
  If Len(Dir(PdfFile)) Then Kill PdfFile
 
  ' Select sheets to be exported in the PDF (single) file
  If MySheets = 0 Then
    ' All sheets to PDF
    Sheets.Select
  Else
    ' Sheets listed in MySheets to PDF
    Sheets(Split(MySheets, ",")).Select
  End If
 
  ' Export the selected sheets as PDF to the temporary folder
  With ActiveSheet
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    .Select
  End With
 
  ' Use the already open Outlook if possible
  On Error Resume Next
  Set OutlApp = GetObject(, "Outlook.Application")
  If Err Then
    Set OutlApp = CreateObject("Outlook.Application")
    IsCreated = True
  End If
  On Error GoTo 0
 
  ' Prepare email with PDF attachment and default signature
  With OutlApp.CreateItem(0)
  
    ' Add the attachment first for correct attachment's name with non English symbols
    .Attachments.Add PdfFile
  
    ' Get default email signature without blinking (instead of .Display method)
    With .GetInspector: End With
    Signature = .Body
 
    ' Prepare e-mail (uncommenmt and fill the lines below)
    .Subject = "Payroll Monthly Analysis"
    .To = Range("L3").Value
    .CC = Range("L4").Value
    .Body = "Hi," & vbLf & vbLf _
          & "Please find the latest payroll report attached" & vbLf & vbLf _
          & Signature
  
    ' Try to send or just display the e-mail
    On Error Resume Next
    If IsDisplay Then .Display Else .Send
  
    ' Show error of .Send method
    If Not IsDisplay Then
      ' Return focus to Excel's window
      Application.Visible = True
      ' Report on error or success
      If Err Then
        MsgBox "E-mail was not sent for some reasons" & vbLf & "Please check it", vbExclamation
        .Display
      Else
        If Not IsSilent Then
          MsgBox "E-mail successfully sent", vbInformation
        End If
      End If
    End If
    On Error GoTo 0
 
  End With
 
  ' Delete the temporary PDF file
  If Len(Dir(PdfFile)) Then Kill PdfFile
 
  ' Try to quit Outlook if it was not previously open
  If IsCreated Then OutlApp.Quit
 
  ' Try to release the memory of object variable
  Set OutlApp = Nothing
 
End Sub
 
Upvote 0
Thank you

Does this do the whole sheet as PDF (certain ranges are just there for calculation therefore these ranges dnt need to be exported as PDF..

I will therefore need certain ranges from the 2 sheets to be exported and then printed also, if its not too much, i will need to attach the workbook also
reason why i need both is because certain managers just want to see the dashboard view (PDF) and certain managers want access to workbook
 
Upvote 0
Hi Mahmed,
Try this code.
Modify constants in the top of the code according to their comments.
Rich (BB code):
Sub Attach_Ranges_With_Signature()
' ZVI:2016-09-20 http://www.mrexcel.com/forum/excel-questions/710212-visual-basic-applications-code-convert-excel-pdf-email-attachment-post4636746.html#post4636746
 
  ' --> User settings, change to suit
  Const Sh1 = "Dashboard"             ' Sheet1 to be attached in PDF
  Const Rng1 = "A1:X500"              ' The range of sheet1
  Const Sh2 = "WeeklyInput"           ' Sheet2 to be attached in that PDF too
  Const Rng2 = "A1:D200"              ' The range of sheet2
  Const IsAttachWb As Boolean = True  ' True to attach active workbook as well
  Const IsDisplay As Boolean = True   ' Change to False to .Send instead of .Display
  Const IsSilent As Boolean = False   ' Change to True to Send without the confirmation MsgBox
  ' <-- End of settings
 
  Dim IsCreated As Boolean
  Dim PdfFile As String, Signature As String
  Dim OutlApp As Object
  Dim i As Long
  Dim char As Variant
 
  ' Prepere Dashboard for PDF
  With Sheets(Sh1).Cells
    .EntireColumn.Hidden = True
    .EntireRow.Hidden = True
    With .Range(Rng1)
      .EntireColumn.Hidden = False
      .EntireRow.Hidden = False
    End With
  End With
 
  ' Prepere Dashboard for PDF
  With Sheets(Sh2).Cells
    .EntireColumn.Hidden = True
    .EntireRow.Hidden = True
    With .Range(Rng2)
      .EntireColumn.Hidden = False
      .EntireRow.Hidden = False
    End With
  End With
 
  ' Define PDF filename
  PdfFile = "Summary"
  ' Add %TEMP% path to the file name and limit too long name
  PdfFile = Left(CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) & "\" & PdfFile, 251) & ".pdf"
 
  ' Try to delete PDF file for the case it was not deleted at debugging
  If Len(Dir(PdfFile)) Then Kill PdfFile
 
  ' Select sheets to be exported in the PDF (single) file
  Sheets(Split("Dashboard,WeeklyInput", ",")).Select
 
  ' Export the selected sheets as PDF to the temporary folder
  With ActiveSheet
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    .Select
  End With
 
  ' Restore Dashboard for PDF
  With Sheets(Sh1).Cells
    .EntireColumn.Hidden = False
    .EntireRow.Hidden = False
  End With
 
  ' Retore Dashboard for PDF
  With Sheets(Sh2).Cells
    .EntireColumn.Hidden = False
    .EntireRow.Hidden = False
  End With
 
  ' Use the already open Outlook if possible
  On Error Resume Next
  Set OutlApp = GetObject(, "Outlook.Application")
  If Err Then
    Set OutlApp = CreateObject("Outlook.Application")
    IsCreated = True
  End If
  On Error GoTo 0
 
  ' Prepare email with PDF attachment and default signature
  With OutlApp.CreateItem(0)
  
    ' Add the attachment first for correct attachment's name with non English symbols
    .Attachments.Add PdfFile
    If IsAttachWb Then .Attachments.Add ThisWorkbook.FullName
  
    ' Get default email signature without blinking (instead of .Display method)
    With .GetInspector: End With
    Signature = .Body
 
    ' Prepare e-mail (uncommenmt and fill the lines below)
    .Subject = "Payroll Monthly Analysis"
    .To = Range("L3").Value
    .CC = Range("L4").Value
    .Body = "Hi," & vbLf & vbLf _
          & "Please find the latest payroll report attached" & vbLf & vbLf _
          & Signature
  
    ' Try to send or just display the e-mail
    On Error Resume Next
    If IsDisplay Then .Display Else .Send
  
    ' Show error of .Send method
    If Not IsDisplay Then
      ' Return focus to Excel's window
      Application.Visible = True
      ' Report on error or success
      If Err Then
        MsgBox "E-mail was not sent for some reasons" & vbLf & "Please check it", vbExclamation
        .Display
      Else
        If Not IsSilent Then
          MsgBox "E-mail successfully sent", vbInformation
        End If
      End If
    End If
    On Error GoTo 0
 
  End With
 
  ' Delete the temporary PDF file
  If Len(Dir(PdfFile)) Then Kill PdfFile
 
  ' Try to quit Outlook if it was not previously open
  If IsCreated Then OutlApp.Quit
 
  ' Try to release the memory of object variable
  Set OutlApp = Nothing
 
End Sub
 
Last edited:
Upvote 0
Hi ZVI,

Firstly i want to say thank you so so so much..

Honestly you dont know how helpful you have been..

I was hoping you could help me with the last bit to go 1 step further..

The top msnagers also like to see PowerPoint prentation slides that focus on each are. We have a default PowerPoint template that is used through the business..

Is it possible to have a PowerPoint reprentation on of each section into its own slides?

e.g

I have named range area Work in progress..

A5:J30 (that is the range that holds my data and the charts)
A35:J55 (that holds another section with charts)etc..

I have several of these ranges named..

I have to every other day copy those ranges and show those sections on PowerPoint on its own slide (resize the image) for that section nicely on each slide so that the senior managers can go through each slide in their meetings..(I normally coppy the range as a picture and then paste into PowerPoint slide and resize) (sometimes the image looks blurry tho

Would that be possible...you would help my day to day job massively if i can automate this and i can imagine helping so many others also who will no doubt have the same problem..

If you can please come up with some code that will do this i am happy to even pay for this to show my appreciation- thank you
 
Upvote 0
Hi everyone.

I'm happy with everything that the attached code does however is it possible to amend the email signature so that it retains the formatting? It is currently coming through as plain text but it is necessary to retain the formatting due to the standardization of our corporate communications.
Code:
[Sub Attach_Sheets_As_Pdf_With_Signature()
' ZVI:2016-09-20 [URL]http://www.mrexcel.com/forum/excel-questions/710212-visual-basic-applications-code-convert-excel-pdf-email-attachment-5.html#post4636678[/URL]
 
  ' --> User settings, change to suit
  Const MySheets As Variant = "SUMMARY,PAYROLL,MILEAGE,OVERTIME" ' Use MySheets = 0 for all the sheets
  Const IsDisplay As Boolean = True           ' Change to False to .Send instead of .Display
  Const IsSilent As Boolean = True           ' Change to True to Send without the confirmation MsgBox
  ' <-- End of settings
 
  Dim IsCreated As Boolean
  Dim PdfFile As String, Signature As String
  Dim OutlApp As Object
  Dim i As Long
  Dim char As Variant
 
  ' Define PDF filename
  PdfFile = ActiveWorkbook.Name
  i = InStrRev(PdfFile, ".xl", , vbTextCompare)
  If i > Len(PdfFile) - 5 Then PdfFile = Left(PdfFile, i - 1)
  PdfFile = PdfFile & "_" & ActiveSheet.Name
  ' Clean up the name of PDF file
  For Each char In Split("? "" / \ < > * | :")
    PdfFile = Replace(PdfFile, char, "_")
  Next
  ' Add %TEMP% path to the file name and limit too long name
  PdfFile = Left(CreateObject("Scripting.FileSystemObject").GetSpecialFolder(2) & "" & PdfFile, 251) & ".pdf"
 
  ' Try to delete PDF file for the case it was not deleted at debugging
  If Len(Dir(PdfFile)) Then Kill PdfFile
 
  ' Select sheets to be exported in the PDF (single) file
  If MySheets = 0 Then
    ' All sheets to PDF
    Sheets.Select
  Else
    ' Sheets listed in MySheets to PDF
    Sheets(Split(MySheets, ",")).Select
  End If
 
  ' Export the selected sheets as PDF to the temporary folder
  With ActiveSheet
    .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    .Select
  End With
 
  ' Use the already open Outlook if possible
  On Error Resume Next
  Set OutlApp = GetObject(, "Outlook.Application")
  If Err Then
    Set OutlApp = CreateObject("Outlook.Application")
    IsCreated = True
  End If
  On Error GoTo 0
 
  ' Prepare email with PDF attachment and default signature
  With OutlApp.CreateItem(0)
  
    ' Add the attachment first for correct attachment's name with non English symbols
    .Attachments.Add PdfFile
  
    ' Get default email signature without blinking (instead of .Display method)
    With .GetInspector: End With
    Signature = .Body
 
    ' Prepare e-mail (uncommenmt and fill the lines below)
    .Subject = "Payroll Monthly Analysis"
    .To = Range("I3").Value
    .CC = Range("I4").Value
    .Body = "Hi," & vbLf & vbLf _
 & "Please find the latest payroll report attached" & vbLf & vbLf _
 & Signature
  
    ' Try to send or just display the e-mail
    On Error Resume Next
    If IsDisplay Then .Display Else .Send
  
    ' Show error of .Send method
    If Not IsDisplay Then
      ' Return focus to Excel's window
      Application.Visible = True
      ' Report on error or success
      If Err Then
        MsgBox "E-mail was not sent for some reasons" & vbLf & "Please check it", vbExclamation
        .Display
      Else
        If Not IsSilent Then
          MsgBox "E-mail successfully sent", vbInformation
        End If
      End If
    End If
    On Error GoTo 0
 
  End With
 
  ' Delete the temporary PDF file
  If Len(Dir(PdfFile)) Then Kill PdfFile
 
  ' Try to quit Outlook if it was not previously open
  If IsCreated Then OutlApp.Quit
 
  ' Try to release the memory of object variable
  Set OutlApp = Nothing
 
End Sub
 
 
/CODE]

Regards

Will
Once again any assistance is greatly appreciated!
 
Upvote 0

Forum statistics

Threads
1,223,919
Messages
6,175,371
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top