Open PDF file based with variant name and file path

YingFa

Board Regular
Joined
Nov 4, 2019
Messages
63
Hello,

I have the below code and I would like to modify it to do what it does right now but to add opening a PDF file that name depends on combobox1 and the file patch varies too. Can I please have your help on this?

VBA Code:
Private Sub CommandButton1_Click()
    
    Dim PCAR As String, oldFolderName As String, newFolderName As String, rowSelect As Long

    If Me.ComboBox1.Value = "" Then
        MsgBox "PR Can Not Be Blank!", vbExclamation, "PR"
        Exit Sub
    End If

    PCAR = ComboBox1.Value

    Application.ScreenUpdating = False
    
    On Error Resume Next
        rowSelect = Me.ComboBox1.ListIndex + 6
        Sheets("Home").Select
        Cells(rowSelect, 16) = Me.TextBox3.Value
        Cells(rowSelect, 15) = "Closed"
    
        oldFolderName = "Z:\QS\001. PR's\" & PR
        newFolderName = "Z:\QS\001. PR's\" & PR & "-Closed"
    
        Name oldFolderName As newFolderName
        
Unload Me

MsgBox PR & " has been closed"
    Application.ScreenUpdating = True


End Sub
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Watch MrExcel Video

Forum statistics

Threads
1,127,554
Messages
5,625,474
Members
416,109
Latest member
TripleA00123

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
Top