the DOT in front of these lines : .Range("C" & RowCount) indicates to use the
property in the WITH statement : With ZoomSht
What error are you getting when the line is highlighted in YELLOW. I don't
have excel 2007 installed on the PC I'm using and the export method isn't
supported in 2003.
I made a couple of minor changes in the code below to see if this solves the
problem. I changed the FOLDER line which was too long. Made two lines. I
also change the export filename to match yoiu original request of having the
email the first item in the filename.
Sub BenefitsReport()
'
' BenefitsReport Macro
'
Folder = "C:\Users\George\Documents\M-Link\Calculators\June 2009\" & _
TDMP Benefits Report\"
FName = "Report.pdf"
'
Set ZoomSht = Sheets("Zoomerang Data")
With ZoomSht
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 11 To LastRow
.Rows(RowCount).Copy _
Destination:=.Rows(2)
Sheets("Benefits Report").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Folder & _
.Range("H" & RowCount) & _
.Range("C" & RowCount) & _
.Range("D" & RowCount) & _
FName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next RowCount
End With
End Sub
GeorgeA said:
Joel, I see what you mean about the filename, but the column data I want to
add to the filename is Column H from the Zoomerang Data sheet, not the
Benefits Report sheet.
I keep getting a debug error and this section is highlighted in yellow:
Sheets("Benefits Report").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Folder & _
.Range("C" & RowCount) & _
.Range("D" & RowCount) & _
FName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Joel said:
The filename is specified here
Filename:=Folder & _
.Range("C" & RowCount) & _
.Range("D" & RowCount) & _
FName, _
You can make whatever changes you need like this
Filename:=Folder & _
.Range("C" & RowCount) & _
.Range("D" & RowCount) & _
.Range("H" & RowCount) & _
FName, _
:
I really appreciate this and the macros do work and loop but the problem is
that they overwrite the report every time because it always has the same
filename. Column H in the Zoomerang Data sheet is the email address which is
unique. Is it possible to have the filename of the report created be named
"[emailaddress] Benefits Report.pdf"
Thanks again.
:
Jacob's code didn't start at row 11 and had a fixed last row of row 15. I
made the last row variable based on the data in the worksheet
Sub BenefitsReport()
'
' BenefitsReport Macro
'
Folder = "C:\Users\George\Documents\M-Link\Calculators\June 2009\TDMP
Benefits Report\"
FName = "Report.pdf"
'
Set ZoomSht = Sheets("Zoomerang Data")
With ZoomSht
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
For RowCount = 11 To LastRow
.Rows(RowCount).Copy _
Destination:=.Rows(2)
Sheets("Benefits Report").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Folder & _
.Range("C" & RowCount) & _
.Range("D" & RowCount) & _
FName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next RowCount
End With
End Sub