I'm working on a book project and therefore self-learning Excel VBA. I can't add Common Dialog to my Userform nor the additional tool I choose is wrong one but it's the only CommonDialog I have. The error code on the end of the video translates to " Interface isn't supported" or something like that.
The video is no help. What do you expect to do with this control?
That's Common Dialog Class, I think you want the Common Dialog Control. I think this control is like the DatePicker control and is not always available.
Also, I think if you are running a 64-bit version then it will not be available
I wouldn't use such a control. If you want to slect a file use thisCode
- Dim oFileDialog As Object
- Dim vSelectedFile As Variant
- Dim FilPath As String
- ''///Browse for file
- Set oFileDialog = Application.FileDialog(3)
- With oFileDialog
- .ButtonName = "Select File"
- .AllowMultiSelect = False
- .Filters.Clear ''///It is important to clear old filters before adding new one
- .Filters.Add "Excel File", "*.xls*", 1 ''///You may add more filters and give them a sequence
- .Title = "Select Input file"
- For Each vSelectedFile In .SelectedItems
- FilPath = vSelectedFile ''///get the path to the file to open
- End With
- ''/// open workbook
- Workbooks.Open FilPath