I did like the one VS offers, it is not the one that OFFICE USES.
I use this VBA code to open a File Dialog box in Excel many times. I create forms and have a button to open it. I like it sicne it is the exact one that Windows uses. It requires this reference. Microsoft Office xx Object Library. xx being the version of Office you have installed. I do not like the File Ddialofg in Visual studio. It is very clumsy when you drill down to many directlries to find a file. It shows the folder picked at the very bottom of its window each time.
I added the only Imports it showed Imports Microsoft.Office.Core but it does not work.
How can I use the Office one in VS? what referene do I need to add? I treid the only one
I added the Microsoft Office xx Object Library but the lines in yellow are not accepted
Code to run the Office Dialog box
DougP
I use this VBA code to open a File Dialog box in Excel many times. I create forms and have a button to open it. I like it sicne it is the exact one that Windows uses. It requires this reference. Microsoft Office xx Object Library. xx being the version of Office you have installed. I do not like the File Ddialofg in Visual studio. It is very clumsy when you drill down to many directlries to find a file. It shows the folder picked at the very bottom of its window each time.
I added the only Imports it showed Imports Microsoft.Office.Core but it does not work.
How can I use the Office one in VS? what referene do I need to add? I treid the only one
I added the Microsoft Office xx Object Library but the lines in yellow are not accepted
Code to run the Office Dialog box
Code:
Dim fDialog As [highlight #FCE94F]Office.FileDialog[/highlight]
Dim varFile As Object
' Set up the File Dialog.
fDialog = [highlight #FCE94F]Application.FileDialog(msoFileDialogFilePicker)[/highlight]
With fDialog
' Allow user to make multiple selections in dialog box
.AllowMultiSelect = True
' Set the title of the dialog box.
.Title = "Please select Resource SOW Workers Excel sheet"
' Clear out the current filters, and add our own.
.Filters.Clear()
.Filters.Add("Access Databases", "*.XLS")
.Filters.Add("All Files", "*.*")
If .Show = True Then
'Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
ExcelFileName = varFile
Next
'import excel file
' DoCmd.TransferSpreadsheet(acImport, acSpreadsheetTypeExcel9, "tmp-SOWResourceList", ExcelFileName, False)
Else
'MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
DougP