Below is VBA I have used to create a folder, convert the file into PDF and name it. I would like to know what lines I need to remove to not create the floder, because I want to send it to a folder that already exists.
Private Sub SendToKatieFolder_Click()
Call ExportPDFINVOICEkatiefolder("C:\Users\hmartinez\Desktop\Katie Weekly Sent Invoices", Me.PropertyAddress, Me.ProjectNumber, Me.InvoiceNumber, Me.BillingCompany, "rptinvoice")
End Sub
Public Sub ExportPDFINVOICEkatiefolder(strRoot As String, strPropertyAddress As String, strprojectnumber As String, strInvoiceNumber As Long, strBillingCompany As String, rpt As String)
On Error GoTo Err_Handler
Dim strPath As String
'Root directory of your file
strPath = strRoot & "\" & strprojectnumber & " " & strPropertyAddress & "\"
Dim strFile As String
'Full address of your file
strFile = strPath & "Invoice" & " " & strInvoiceNumber & " " & strBillingCompany & " " & strPropertyAddress & " " & "Project Number" & " " & strprojectnumber & ".pdf"
'Does the directory exist? If not, create it
If Exist(strPath, vbDirectory) = 0 Then MkDir (strPath)
'Does the file exist?
If Exist(strFile) Then
Dim intResponse As Integer
intResponse = MsgBox("That file already exists! Would you like to replace it?", vbYesNo, "Error")
If intResponse = vbYes Then
Kill (strFile)
Else
Exit Sub
End If
End If
DoCmd.OutputTo acOutputReport, rpt, acFormatPDF, strFile, , , , acExportQualityPrint
Exit_Sub:
Exit Sub
Err_Handler:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Sub
End Sub
Private Sub SendToKatieFolder_Click()
Call ExportPDFINVOICEkatiefolder("C:\Users\hmartinez\Desktop\Katie Weekly Sent Invoices", Me.PropertyAddress, Me.ProjectNumber, Me.InvoiceNumber, Me.BillingCompany, "rptinvoice")
End Sub
Public Sub ExportPDFINVOICEkatiefolder(strRoot As String, strPropertyAddress As String, strprojectnumber As String, strInvoiceNumber As Long, strBillingCompany As String, rpt As String)
On Error GoTo Err_Handler
Dim strPath As String
'Root directory of your file
strPath = strRoot & "\" & strprojectnumber & " " & strPropertyAddress & "\"
Dim strFile As String
'Full address of your file
strFile = strPath & "Invoice" & " " & strInvoiceNumber & " " & strBillingCompany & " " & strPropertyAddress & " " & "Project Number" & " " & strprojectnumber & ".pdf"
'Does the directory exist? If not, create it
If Exist(strPath, vbDirectory) = 0 Then MkDir (strPath)
'Does the file exist?
If Exist(strFile) Then
Dim intResponse As Integer
intResponse = MsgBox("That file already exists! Would you like to replace it?", vbYesNo, "Error")
If intResponse = vbYes Then
Kill (strFile)
Else
Exit Sub
End If
End If
DoCmd.OutputTo acOutputReport, rpt, acFormatPDF, strFile, , , , acExportQualityPrint
Exit_Sub:
Exit Sub
Err_Handler:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Sub
End Sub