I have a monthly report that is exported for each of the sales reps, detailing their advertisers activity. I have an access report which compiles all of these reports into a single multipage PDF. Which I must then use Acrobat to break into individual PDF's. These PDF's must then be placed in that reps folder on our shared drive.
Since the above is a time consuming process I am trying to a VBA module to do this for me in one step.
This is what I have so far
I have set this up so that the path to the root folder is stored in one of my tables as "path". This would by queried in as the root folder, and the VBA would append "\" & Year[] & "\" & month[] & "\" repFname & "\", and place all of the individually exported PDF's within the appropriate folder.
Ultimately I want a folder for each month, then within that folder I want a folder for each rep, then that rep's files in their folder. I am storing the path in the database because this this report will export for a couple of divisions within the company, each of which use their own folder tree. This way you can enter the root directory once as an initial setup configuration.
My problem is the section of code which is commented out. The rest of the code seems to work well. I dont really know how to accomplish the creation of the folders.
Since the above is a time consuming process I am trying to a VBA module to do this for me in one step.
This is what I have so far
Code:
Public Function ExportToPDF()
Const qryName = "MasterQuery"
Const PK = "id"
Const name = "Advertiser"
Const Path = "path"
Const dir = "repFname"
Const rptName = "MasterReport"
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset(qryName)
Do While Not rs.EOF
'If dir(rs.Fields(Path) & "\" & rs.Fields(dir) & "\") Is "" Then
'MkDir (rs.Fields(Path) & "\" & rs.Fields(dir) & "\")
'End If
DoCmd.OpenReport rptName, acViewPreview, , PK & " = " & rs.Fields(PK)
DoCmd.OutputTo acOutputReport, rptName, acFormatPDF, rs.Fields(Path) & "\" & rs.Fields(dir) & "\" & rs.Fields(name) & ".pdf"
DoCmd.Close acReport, rptName
rs.MoveNext
Loop
End Function
Ultimately I want a folder for each month, then within that folder I want a folder for each rep, then that rep's files in their folder. I am storing the path in the database because this this report will export for a couple of divisions within the company, each of which use their own folder tree. This way you can enter the root directory once as an initial setup configuration.
My problem is the section of code which is commented out. The rest of the code seems to work well. I dont really know how to accomplish the creation of the folders.