thst
Gebruiker
- Lid geworden
- 10 apr 2001
- Berichten
- 655
Hallo Allemaal,
Ben echt wanhopig, heb van alles geprobeerd, tot vannacht 2:30 uur bezig geweest maar kom er niet uit.
Met de MsgBox wil ik of Printen of Mailen in beide gevallen moet die wel PDF Creator uitvoeren.
Wie wil me helpen ?
Sub opslaan_en_mailen()
'If MsgBox("Wil Je Deze Woning Opslaan?", vbQuestion + vbYesNo) = vbYes Then
'If lAnswer = vbYes Then
'End If
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Print to PDF file using PDFCreator
' (Download from http://sourceforge.net/projects/pdfcreator/)
' Designed for late bind, no references req'd
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
MyName = Range("d2").Value & ""
'/// Change the output file name here! ///
sPDFName = MyName & ".xls"
'"testPDF.pdf"
sPDFPath = "d:\test\"
'ActiveWorkbook.Path & Application.PathSeparator
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Print the document to PDF
ActiveSheet.PrintOut Copies:=1, ActivePrinter:="PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing
ActiveSheet.PrintOut Copies:=1, ActivePrinter:="HP LaserJet 4100 PCL 6"
'versturen van pdf via mail
Set App = CreateObject("Outlook.Application")
Set Itm = App.CreateItem(0)
With Itm
.Subject = "Bijgaand de factuur, en bevestiging aflevering."
.To = Range("d5").Value & "" 'vul hier een mail adres in
.CC = ""
.Bcc = ""
.Body = Range("A1").Value & Range("D13").Value & vbNewLine & vbNewLine & Range("A2").Value & vbNewLine & Range("A3").Value & vbNewLine & vbNewLine & Range("A4").Value & vbNewLine & Range("A5").Value & vbNewLine & vbNewLine & Range("A6").Value & vbNewLine & Range("A7").Value & vbNewLine & Range("A8").Value & vbNewLine & vbNewLine & Range("A9").Value & vbNewLine & vbNewLine & Range("A10").Value
.Attachments.Add sPDFPath & "\" & Replace(sPDFName, "xls", "pdf") 'Factuur word verzonden.(0123456789.pdf)
.Attachments.Add sPDFPath & "\" & (Range("D7").Value) 'Bevestiging word verzonden (0123456789v.pdf)
'.Display
'.Save
.Send
End With
'End If
End Sub
Angela
Ben echt wanhopig, heb van alles geprobeerd, tot vannacht 2:30 uur bezig geweest maar kom er niet uit.
Met de MsgBox wil ik of Printen of Mailen in beide gevallen moet die wel PDF Creator uitvoeren.
Wie wil me helpen ?
Sub opslaan_en_mailen()
'If MsgBox("Wil Je Deze Woning Opslaan?", vbQuestion + vbYesNo) = vbYes Then
'If lAnswer = vbYes Then
'End If
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Print to PDF file using PDFCreator
' (Download from http://sourceforge.net/projects/pdfcreator/)
' Designed for late bind, no references req'd
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String
MyName = Range("d2").Value & ""
'/// Change the output file name here! ///
sPDFName = MyName & ".xls"
'"testPDF.pdf"
sPDFPath = "d:\test\"
'ActiveWorkbook.Path & Application.PathSeparator
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Print the document to PDF
ActiveSheet.PrintOut Copies:=1, ActivePrinter:="PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing
ActiveSheet.PrintOut Copies:=1, ActivePrinter:="HP LaserJet 4100 PCL 6"
'versturen van pdf via mail
Set App = CreateObject("Outlook.Application")
Set Itm = App.CreateItem(0)
With Itm
.Subject = "Bijgaand de factuur, en bevestiging aflevering."
.To = Range("d5").Value & "" 'vul hier een mail adres in
.CC = ""
.Bcc = ""
.Body = Range("A1").Value & Range("D13").Value & vbNewLine & vbNewLine & Range("A2").Value & vbNewLine & Range("A3").Value & vbNewLine & vbNewLine & Range("A4").Value & vbNewLine & Range("A5").Value & vbNewLine & vbNewLine & Range("A6").Value & vbNewLine & Range("A7").Value & vbNewLine & Range("A8").Value & vbNewLine & vbNewLine & Range("A9").Value & vbNewLine & vbNewLine & Range("A10").Value
.Attachments.Add sPDFPath & "\" & Replace(sPDFName, "xls", "pdf") 'Factuur word verzonden.(0123456789.pdf)
.Attachments.Add sPDFPath & "\" & (Range("D7").Value) 'Bevestiging word verzonden (0123456789v.pdf)
'.Display
'.Save
.Send
End With
'End If
End Sub
Angela