ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,726
- Office Version
- 2007
- Platform
- Windows
Hi,
I have the code below but doesnt work as it should.
My userform opens & i go to the customer in question.
In the form at TxtCustomer i have name of the customer,example TOM JONES 001
All customer files are saved here.
"C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\"
So my goal is to run the code on the command button & look at customers name, then using the path print the file in question.
The below works to a point.
I am on my DATABASE WORKSHEETt, i op[en the userform & brpwse to a customer.
I use the command button to print the file in question.
The file is open in the path shown BUT when it starts to print it doesnt print the file shown on my screen BUT the DATABASE WORKSHEET.
Do you see why
Thanks
I have the code below but doesnt work as it should.
My userform opens & i go to the customer in question.
In the form at TxtCustomer i have name of the customer,example TOM JONES 001
All customer files are saved here.
"C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\"
So my goal is to run the code on the command button & look at customers name, then using the path print the file in question.
The below works to a point.
I am on my DATABASE WORKSHEETt, i op[en the userform & brpwse to a customer.
I use the command button to print the file in question.
The file is open in the path shown BUT when it starts to print it doesnt print the file shown on my screen BUT the DATABASE WORKSHEET.
Do you see why
Thanks
Rich (BB code):
Private Sub PrintInvoice_Click()
Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\"
If txtInvoiceNumber = "N/A" Or Len(txtInvoiceNumber) = 0 Then
MsgBox "INVOICE N/A FOR THIS CUSTOMER", vbExclamation, "N/A INVOICE NOTICE"
Else
If Len(Dir(FILE_PATH & txtInvoiceNumber.Value & ".pdf")) = 0 Then
If MsgBox("Would You Like To Open The Folder ?", vbCritical + vbYesNo, "Warning Invoice is Missing.") = vbYes Then
CreateObject("Shell.Application").Open ("C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\")
End If
Else
CreateObject("Shell.Application").Open (FILE_PATH & txtInvoiceNumber.Value & ".pdf")
End If
End If
ActiveWindow.SelectedSheets.PrintOut copies:=1
End Sub