I am using some code that I have modified and added to form various threads on here- especially the very long one about emailing individual tabs as pdfs to specific individuals (which is basically what I want it to do). I have got most of it to do what I want but my current issue is that I want the pdf filename to start with a date referenced from a cell on the activesheet.
My current code names the file based on the filename then the bit I want then some text then the tab name. This also saves the pdfs produced in the same folder as the spreadsheet.
Extract below:
I thought that I could achieve what I wanted by putting the red line in place of the one above, as this simply rearranges the order of the existing items, but that didnt work.
I can modify the line and make it simpler but then I had to remove the PdfFile = ActiveWorkbook.FullName line as well and it works but no longer saves the pdf file as well as generating the email?
First time noob poster so sorry I have not explained or pasted that very well....
Cheers
My current code names the file based on the filename then the bit I want then some text then the tab name. This also saves the pdfs produced in the same folder as the spreadsheet.
Extract below:
Rich (BB code):
' Define PDF filename
PdfFile = ActiveWorkbook.FullName
i = InStrRev(PdfFile, ".")
If i > 1 Then PdfFile = Left(PdfFile, i - 1)
PdfFile = PdfFile & Format(ActiveSheet.Range("E2").Value, "mmm yy") & " Monthly P&L " & ActiveSheet.Name & ".pdf"
'PdfFile = Format(ActiveSheet.Range("E2").Value, "mmm yy") & PdfFile & " Monthly P&L " & ActiveSheet.Name & ".pdf"
' Export activesheet as PDF
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
I thought that I could achieve what I wanted by putting the red line in place of the one above, as this simply rearranges the order of the existing items, but that didnt work.
I can modify the line and make it simpler but then I had to remove the PdfFile = ActiveWorkbook.FullName line as well and it works but no longer saves the pdf file as well as generating the email?
First time noob poster so sorry I have not explained or pasted that very well....
Cheers
Last edited by a moderator: