file dialog box

AlohaJulio

Board Regular
Joined
Feb 10, 2004
Messages
188
I'm tying to set up a file dialog box to use with TransferSpreadsheet to allow choosing which file to import. I got this from http://support.microsoft.com/default.aspx?kbid=279508 but I'm not able to make it work It gets stuck on the Dim fDialog line. I'm using Access 2002. Can you offer any suggestions?

Option Compare Database
Option Explicit

Private Sub cmdFileDialog_Click()

'Requires reference to Microsoft Office 10.0 Object Library.

Dim fDialog As Office.FileDialog
Dim varFile As Variant

'Clear listbox contents.
Me.FileList.RowSource = ""

'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box
.AllowMultiSelect = True

'Set the title of the dialog box.
.Title = "Please select one or more files"

'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
.Filters.Add "Access Projects", "*.ADP"
.Filters.Add "All Files", "*.*"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
Me.FileList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub

Thanks!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
'Requires reference to Microsoft Office 10.0 Object Library.

Have you made this reference?

In any module, Tools>References... Then select the required reference.

HTH

Peter
 
Upvote 0
I did go into Tools>Reference, and the Microsoft Office 10.0 Object Library was already selected.

Any other tips?
 
Upvote 0
OK, I just tried doing the example from the knowledge base in a new db and it worked no problem.

Only thing that I can suggest is to try moving the reference higher in the list.
Goto Tools>references and use the arrow to move it up.

If that does not work you could try building it in a new db like I did to make sure there is not a problem with the pc

Peter
 
Upvote 0
When I put the button in the form for the first time, a wizard pops up asking what action to do when the button is pushed. Can you tell me which option I should choose? I have been cancelling from the wizard then making changes in the properties of the button. Same issue/question for the list box as well.

I tried creating the form in a new db as recommended, and I realized that this might be the problem and I had left it out of my previous problem description.
 
Upvote 0
Turn the wizard of before starting (top right button on the tool bar)

If you like I can zip up the db I used to test it and E-mail it to you in the morning(my time :) )

Peter
 
Upvote 0

Forum statistics

Threads
1,221,798
Messages
6,162,027
Members
451,737
Latest member
MRASHLEY

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