Opening a PDF using 2 comboboxes on an userform

JChaney17

New Member
Joined
Feb 25, 2013
Messages
18
Greetings,

I am trying put together an userform that will open a PDF file from a folder location dependent on 2 comboboxes. The first combobox gives the user a choice of 3 types, and then the second combobox will provide the user the choice of files to open. I want the user to be able to choose that file in the second combobox and then hit open an file button to open the PDF file from the known file location.

This is my code my code so far:

Private Sub cboType_Change()
'Populates the second combobox
Dim index As Integer
index = cboType.ListIndex
cboChassisSpec.Clear
Select Case index
Case Is = 0 'If car type altered is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 10.2 Altered"
.AddItem "SFI Spec 10.3 Altered"
End With
Case Is = 1 'If car type door cars is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 25.1H Full Bodied Car"
.AddItem "SFI Spec 25.2C Full Bodied Car"
End With
Case Is = 2 'If car type dragster is chosen in combobox1
With cboChassisSpec
.AddItem "SFI Spec 2.5C RED"
.AddItem "SFI Spec 2.7C RED"
End With
End Select
End Sub


Private Sub cmdClose_Click()
Unload Me 'Close the userform

End Sub


Private Sub UserForm_Initialize()
'Populate first combobox with initial car categories

cboType.AddItem "Altereds" 'first car type
cboType.AddItem "Door Cars" 'second car type
cboType.AddItem "Dragsters" 'third car type
End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Using Query Close event of Userform

'Comparing the constant value of CloseMode variable
'If it is equal to inbuilt constant of control menu
'Then prevent closing of userform and
'Display information message dialog box
If CloseMode = vbFormControlMenu Then

'Changing Cancel variable value to True
'By default, it is False
Cancel = True
MsgBox "You can't close the dialog like this!"
End If
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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