hallo beste forumleden,
ik zou graag volgende code gebruiken maar in plaats dat alle werkbladen met een email adres in cel A1 verzonden worden zou enkel het actieve blad mogen verzonden worden naar het email adres van cel A1.
ik loop steeds vast en had graag hulp bij het aanpassen.
Alvast bedankt op voorhand!
ik zou graag volgende code gebruiken maar in plaats dat alle werkbladen met een email adres in cel A1 verzonden worden zou enkel het actieve blad mogen verzonden worden naar het email adres van cel A1.
Code:
'Working only in 2007 and up
Dim sh As Worksheet
Dim TempFilePath As String
Dim TempFileName As String
Dim FileName As String
'Temporary path to save the PDF files
'You can also use another folder like
'TempFilePath = "C:\Users\Ron\MyFolder\"
TempFilePath = Environ$("temp") & "\"
'Loop through every worksheet
For Each sh In ThisWorkbook.Worksheets
FileName = ""
'Test A1 for a mail address
If sh.Range("A1").Value Like "?*@?*.?*" Then
'If there is a mail address in A1 create the file name and the PDF
TempFileName = TempFilePath & "Sheet " & sh.Name & " of " _
& ThisWorkbook.Name & " " _
& Format(Now, "dd-mmm-yy h-mm-ss") & ".pdf"
FileName = RDB_Create_PDF(Source:=sh, _
FixedFilePathName:=TempFileName, _
OverwriteIfFileExist:=True, _
OpenPDFAfterPublish:=False)
'If publishing is OK create the mail
If FileName <> "" Then
RDB_Mail_PDF_Outlook FileNamePDF:=FileName, _
StrTo:=sh.Range("A1").Value, _
StrCC:="", _
StrBCC:="", _
StrSubject:="This is the subject", _
Signature:=True, _
Send:=False, _
StrBody:="<H3><B>Dear Customer</B></H3><br>" & _
"<body>See the attached PDF file with the last figures." & _
"<br><br>" & "Regards Ron de bruin</body>"
Else
MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
"Microsoft Add-in is not installed" & vbNewLine & _
"You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
"The path to Save the file in arg 2 is not correct" & vbNewLine & _
"You didn't want to overwrite the existing PDF if it exist"
End If
End If
Next sh
End Sub
ik loop steeds vast en had graag hulp bij het aanpassen.
Alvast bedankt op voorhand!