Hi All,
I've been beating my head against a wall trying to figure this out. I have a DB set up and running that needs to import an excel spreadsheet to update various table. I have a working solution using a save import, but I don't want each new user/computer to need to set up the saved import and be restricted to exact file name and folder.
I don't have much experience with VBA
.
I would like to set it up so the user will press a button that will prompt them to browse to their file location so they can x2 click to import.
I tried a few variations of file dialog use from the web that worked in videos but when I try them on my machine I get this error
"Compile error
User-defined type not defined"
When I try to run it from the VBA editor with F5 I get a message box to enter a macro name.
I have Private Sub ImportVendorTemplate_Click()
set to match my button
I have "Microsoft Office xx Object Library" checked but no luck.
The VBA below is not for .xlsx but I tried to use it to see if I could get anything to work.
Below is the VBA:
Private SubImportVendorTemplate_Click()
Dim fd As FileDialog
Set fd =Application.FileDialog(msoFileDialogFileopen)
With fd
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Any File","*.*", 1
.Filters.Add "Comma SeparatedFile", "*.csv; *.txt", 2
.Filters.Index = 2
If .Show = True Then
Me.txtFileName.Value =.SelectedItems.Item(1)
End If
End With
End Sub
Thanks in advance!