Villalobos
Active Member
Hi,
I would like to ask some help regarding file opening. My target is that if the specified file is somewhere on device "E" then the code open it (enough to give the filename in "Combobox1" only ). Unfortunately the currently used code open the file if the path is exactly defined.
Could somebody help me how to do it?
I would like to ask some help regarding file opening. My target is that if the specified file is somewhere on device "E" then the code open it (enough to give the filename in "Combobox1" only ). Unfortunately the currently used code open the file if the path is exactly defined.
Code:
Private Sub CommandButton1_Click()
Dim DirFile As String
Dim WB As Variant
DirFile = "E:\Home\AB\CD " & ComboBox1 & ".xlsm"
If Len(Dir(DirFile)) = 0 Then
MsgBox "File does not exist in this folder!"
Else
Set WB = Workbooks.Open(DirFile)
End If
End Sub
Could somebody help me how to do it?