help with email code please

Status
Not open for further replies.

flyinghigher2014

New member
Joined
May 12, 2016
Messages
13
Reaction score
0
Points
0
Hi Everyone

i have this code 1 inside Code 2,

Code:
[COLOR=#333333]
[/COLOR]

'Print the invoice to PDFSub PrintPDFInvoice() 'turn off screenupdating Application.ScreenUpdating = False   If Range("N13") = "" Then MsgBox "Please Enter The Invoice Date" Exit Sub   ElseIf Range("N16") = "" Then MsgBox "Please Enter The Start Date For Your Contract Hire" Exit Sub   ElseIf Range("N17") = "" Then MsgBox "Please Enter The End Date For Your Contract Hire" Exit Sub   ElseIf Range("G12") = "" Then MsgBox "Please add the company" Exit Sub   End If 'open dialog and set file type Opendialog = Application.GetSaveAsFilename(Sheet2.Range("N15") & Sheet2.Range("N14"), filefilter:="PDF Files (*.pdf), *.pdf", _ Title:="Save Me Baby!!") 'if no value is added for file name If Opendialog = False Then MsgBox "I take it you forgot to do something!!" Exit Sub End If 'set the named range for the PDF Set MyRange = Sheet2.Range("G6:N54") Sheet2.PageSetup.PrintArea = "G6:N54" 'create the PDF On Error Resume Next MyRange.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=Sheet2.Range("N15") & Sheet2.Range("N14"), _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=True On Error GoTo 0 'clear the page breaks ActiveSheet.DisplayPageBreaks = False Application.ScreenUpdating = False   Application.Dialogs(xlDialogSendMail).Show  End Sub
when i use code 2 it save the file as required by combining two cells "our0112". but what happens is when i add code 1 it simply opens outlook and adds the original file, and not the saved pdf. could someone please help with this.

also id like the the email to be sent to an email address that i have to the client that is select on the invoice (vlookup, i think). so if i select KN Group then the email that i have for that client would be used. eg sales@kn-group.ie and if i change the client on the invoice to GE Lighting then then email for that client would be used.

im sorry if it all sounds complicated.

ive attached my file as i thought that would help

thank you in advance
Paul
 

Attachments

  • Invoicing.xlsm
    337.3 KB · Views: 16
Last edited by a moderator:
im really sorry admin for some reason i cant edit this post to put code in brackets
 
Code 2
Code:
Code:
[COLOR=#333333][COLOR=#333333]
'Print the invoice to PDFSub PrintPDFInvoice()'turn off screenupdatingApplication.ScreenUpdating = FalseIf Range("N13") = "" ThenMsgBox "Please Enter The Invoice Date"Exit SubElseIf Range("N16") = "" ThenMsgBox "Please Enter The Start Date For Your Contract Hire"Exit SubElseIf Range("N17") = "" ThenMsgBox "Please Enter The End Date For Your Contract Hire"Exit SubElseIf Range("G12") = "" ThenMsgBox "Please add the company"Exit SubEnd If'open dialog and set file typeOpendialog = Application.GetSaveAsFilename(Sheet2.Range("N15") & Sheet2.Range("N14"), filefilter:="PDF Files (*.pdf), *.pdf", _Title:="Save Me Baby!!")'if no value is added for file nameIf Opendialog = False ThenMsgBox "I take it you forgot to do something!!"Exit SubEnd If'set the named range for the PDFSet MyRange = Sheet2.Range("G6:N54")Sheet2.PageSetup.PrintArea = "G6:N54"'create the PDFOn Error Resume NextMyRange.ExportAsFixedFormat _Type:=xlTypePDF, _Filename:=Sheet2.Range("N15") & Sheet2.Range("N14"), _Quality:=xlQualityStandard, _IncludeDocProperties:=True, _IgnorePrintAreas:=False, _OpenAfterPublish:=TrueOn Error GoTo 0'clear the page breaksActiveSheet.DisplayPageBreaks = FalseApplication.ScreenUpdating = FalseApplication.Dialogs(xlDialogSendMail).Show End Sub[/COLOR][/COLOR]

Code:
[COLOR=#333333]Application.Dialogs(xlDialogSendMail).Show[/COLOR]
 
im really sorry admin for some reason i cant edit this post to put code in brackets

The code in post #1 is unusable as is. Post or send me a text file containing it under usual form, and I will edit your post to make it usable so you can be helped
 
code

The code in post #1 is unusable as is. Post or send me a text file containing it under usual form, and I will edit your post to make it usable so you can be helped

attached is the text file
 

Attachments

  • for forum in outlook section.txt
    2.1 KB · Views: 15
Thanks
There seems to be a problem with the code tags. I'll send a message to admin to see what's going on. Sorry.

Meanwhile I will close this thread and move your post in VBA programming to Outlook. The format seems OK there.

If you need to contact me you can also PM.
 
Hey there,

Yes, every now and then, the code tags eat all the hard returns. I don't know why, and I haven't figured out what the trigger point is.

I'm not saying that this is the best answer but when this happens to me I copy and paste the original code to Notepad, then copy it into the post. It's irritating to be sure.

The only way to fix it now is to go through and re-insert the hard returns. Pretty long piece of code though. :(
 
Status
Not open for further replies.
Back
Top