kareltje555
Gebruiker
- Lid geworden
- 22 sep 2011
- Berichten
- 70
VB geeft volgende foutmelding en ik heb al zitten vogelen met pad namen en dergelijke \wanneer ik bij pdffile alles weglaat en alleen ".pdf" neerzet dan werkt het wel/ bedoeling is juist dat de file wordt weggeschreven in de map onofhold
fout 1004 tijdens uitvoering
het document is niet opgeslagen. mogelijk is het document nog geopend of is er een fout opgetreden bij het opslkaan van het document.
Sub mail_onofhold_met_pdf()
Dim IsCreated As Boolean
Dim Title As String
Dim OutlApp As Object
Dim pdffile As String
Dim strto As String
Dim strcc As String
Dim strbcc As String
Sheets("OnOfHold").Select
' Not sure for what the Title is
Title = ActiveSheet.Range("b7").Value & ActiveSheet.Range("i100").Value
>>>>>>>> pdffile = ThisWorkbook.Path & "\onofhold" & ActiveSheet.Range("i100").Value & ".pdf"
strto = ActiveSheet.Range("d107")
strcc = ActiveSheet.Range("d109")
strbcc = ActiveSheet.Range("d111")
With Sheets("onofhold").Range("b1:i59")
.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=pdffile, _
quality:=qlqualitystandard, _
includedocproperties:=True, _
IgnorePrintAreas:=False, _
openafterpublish:=False
End With
' Use 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
OutlApp.Visible = True
On Error GoTo 0
' Prepare e-mail with PDF attachment
With OutlApp.CreateItem(0)
' Prepare e-mail
.subject = Title
.To = strto '"charles.deckers@kpnmail.nl" ' <-- Put email of the recipient here
.cc = strcc ' <-- Put email of 'copy to' recipient here
.BCC = strbcc
.Body = "Geachte geadresseerde," & vbLf & vbLf _
& "Bijgaande treft u het bestand aan in PDF format." & vbLf & vbLf _
& "met vriendelijke groet," & vbLf _
& Application.username & vbLf & vbLf
.Attachments.Add pdffile
' Try to send
On Error Resume Next
.Send
Application.Visible = True
If Err Then
MsgBox "E-mail was not sent", vbExclamation
Else
MsgBox "E-mail successfully sent", vbInformation
End If
On Error GoTo 0
End With
fout 1004 tijdens uitvoering
het document is niet opgeslagen. mogelijk is het document nog geopend of is er een fout opgetreden bij het opslkaan van het document.
Sub mail_onofhold_met_pdf()
Dim IsCreated As Boolean
Dim Title As String
Dim OutlApp As Object
Dim pdffile As String
Dim strto As String
Dim strcc As String
Dim strbcc As String
Sheets("OnOfHold").Select
' Not sure for what the Title is
Title = ActiveSheet.Range("b7").Value & ActiveSheet.Range("i100").Value
>>>>>>>> pdffile = ThisWorkbook.Path & "\onofhold" & ActiveSheet.Range("i100").Value & ".pdf"
strto = ActiveSheet.Range("d107")
strcc = ActiveSheet.Range("d109")
strbcc = ActiveSheet.Range("d111")
With Sheets("onofhold").Range("b1:i59")
.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=pdffile, _
quality:=qlqualitystandard, _
includedocproperties:=True, _
IgnorePrintAreas:=False, _
openafterpublish:=False
End With
' Use 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
OutlApp.Visible = True
On Error GoTo 0
' Prepare e-mail with PDF attachment
With OutlApp.CreateItem(0)
' Prepare e-mail
.subject = Title
.To = strto '"charles.deckers@kpnmail.nl" ' <-- Put email of the recipient here
.cc = strcc ' <-- Put email of 'copy to' recipient here
.BCC = strbcc
.Body = "Geachte geadresseerde," & vbLf & vbLf _
& "Bijgaande treft u het bestand aan in PDF format." & vbLf & vbLf _
& "met vriendelijke groet," & vbLf _
& Application.username & vbLf & vbLf
.Attachments.Add pdffile
' Try to send
On Error Resume Next
.Send
Application.Visible = True
If Err Then
MsgBox "E-mail was not sent", vbExclamation
Else
MsgBox "E-mail successfully sent", vbInformation
End If
On Error GoTo 0
End With