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
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,214,632
Messages
6,120,649
Members
448,975
Latest member
sweeberry

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