Hi Guy's Vlad gladly helped me on this, the issue i am having now if someone can correct/highlight the code, Excel is not closing correctly and having to use Ctrl Alt Delete to task manager and close excel by ending task
I have at the bottom of my code what i thought would close it ??
Code:
Case 2 Set apXL = CreateObject("Excel.Application")
Set xlWB = apXL.Workbooks.Open(pOpen & fOpen)
apXL.Workbooks.Open pOpen & fOpen, True, False
apXL.Visible = False
pdfPath = "T:\Removed\PDF\Invoices\" & myCust & "\"
pdfFile = myCust & " " & InvNo & ".pdf"
If Len(Dir(pdfPath, vbDirectory)) = 0 Then
MkDir (pdfPath)
Else
DoCmd.CancelEvent
End If
xlWB.ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=pdfPath & pdfFile
a = TOD & " " & myClient
b = "Please find attached your invoice for your kind attention."
c = "With Kind Regards"
d = Forms!frmMainMenu!txtLogin
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
Set OutAccount = oEmailItem.Session.Accounts.Item(2)
.To = myEmail
.Subject = "Invoice Attached"
.Attachments.Add pdfPath & pdfFile
.HTMLBody = a & "<br>" & "<br>" & b & "<br>" & "<br>" & c & "<br>" & "<br> " & _
d & "<br>" & "<br>" & _
"<P><IMG border=0 hspace=0 alt='' src='file://T:/Removed/Email Signature.jpg' align=baseline></P>" & "<br>" & "<br>" & _
"<FONT color=#0000CD>" & eDisc & "<br>" & "<FONT color =#0000CD>" & eDisc2
.SendUsingAccount = OutAccount
.Display
End With
End Select
End If
Set xlWB = Nothing
Set apXL = Nothing