Userform print pdf with file name and path

sureshtrb

Board Regular
Joined
Mar 24, 2013
Messages
106
I am not an expert in vba and with the forum guide created userform and works well.
I want to save the userform in pdf with textbox file name which i am trying for the past 2 days and unsuccessful.
advice requested.
my code
Code:
Dim OldPrinter As String, NewPrinter As String    OldPrinter = Left$(Application.ActivePrinter, InStrRev(Application.ActivePrinter, "on ") - 2)
    Application.Dialogs(xlDialogPrinterSetup).Show
    NewPrinter = Left$(Application.ActivePrinter, InStrRev(Application.ActivePrinter, "on ") - 2)


    
    Dim sFilename As String
    Dim cname, tagNumber, customer, newHour, newMinute, newSecond, waitTime
    Dim fpath As String
    
    With rvcform
            newHour = Hour(Now())
            newMinute = Minute(Now())
            newSecond = Second(Now()) + 2
            waitTime = TimeSerial(newHour, newMinute, newSecond)
            Application.Wait waitTime
            cname = NO.Value
            tagNumber = TAGN.Value
            customer = CUSTO.Value
            sFilename = customer & "-RVC-" & cname & "-" & tagNumber & ".pdf"
            fpath = "C:\Users\VSD\Desktop\RVC_Printed_Copies\"
     
            Application.ScreenUpdating = True
            SendKeys fpath & sFilename & "{ENTER}", False
            MsgBox fpath & sFilename
            .PrintForm
        End With

Everytime when print, it prompts for "Microsoft Visual Basic" as file name instead of the given file name.
Help please!
 
Thanks so much for digging out the code. I really appreciate it. The printing worked fine. Thanks again!:)
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,214,865
Messages
6,121,988
Members
449,060
Latest member
mtsheetz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top