D J
asked on
MS Access How can I add a relative path to my VBA PDF output that will work for most Windows computers?
Is there a relative path I can add to the VBA below to dump the PDF into the Documents or My Documents folder in a variety of Windows OS's?
If Len(where) > 0 Then
where = Left(where, Len(where) - 1)
DoCmd.OpenReport "rpt_SW_Report_By_H", acViewPreview, , "lc_craftsid IN (" & where & ")", acHidden
DoCmd.OutputTo acOutputReport, "rpt_SW_Report_By_H", acFormatPDF, "C:\Test\rpt_SW_Report_By_H .pdf", True
End If
If Len(where) > 0 Then
where = Left(where, Len(where) - 1)
DoCmd.OpenReport "rpt_SW_Report_By_H", acViewPreview, , "lc_craftsid IN (" & where & ")", acHidden
DoCmd.OutputTo acOutputReport, "rpt_SW_Report_By_H", acFormatPDF, "C:\Test\rpt_SW_Report_By_H
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
correction on typo
Dim xFolder As String
xFolder = Environ("UserProfile") & "\Documents"
If Dir(xFolder, vbDirectory) = "" Then
xFolder = Environ("UserProfile") & "\My Documents"
End If
DoCmd.OutputTo acOutputReport, "rpt_SW_Report_By_H", acFormatPDF, xFolder & "\rpt_SW_Report_By_H.pdf", True
Dim xFolder As String
xFolder = Environ("UserProfile") & "\Documents"
If Dir(xFolder, vbDirectory) = "" Then
xFolder = Environ("UserProfile") & "\My Documents"
End If
DoCmd.OutputTo acOutputReport, "rpt_SW_Report_By_H", acFormatPDF, xFolder & "\rpt_SW_Report_By_H.pdf",
ASKER
Worked perfectly!
Open in new window