filedialog filepicker and folderpicker

B

bill

How can the filepicker or folderpicker be used for the user to enter a new
file name? This will be used with the transferspreadsheet method to export
data to a spreadsheet.

After I pick a folder with the folderpicker, I can't enter a filename in the
dialog box, or I get file not found error. With the filepicker, if I enter
the name of a non-existent folder, of course I get the file not found error.


I want the user to be able to browse to the folder and enter the name of a
new file to be created.
 
B

BillE

How about using the Access 2003/2007 filedialog?

Sub Filepicker()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog

'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)

'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant

'Use a With...End With block to reference the FileDialog object.
With fd

'Use the Show method to display the File Picker dialog box
'The user pressed the action button.
If .Show = -1 Then

'Step through the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems

'vrtSelectedItem contains the path of each selected item.
'Here use any file I/O functions you want on the path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem

Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With

'Set the object variable to Nothing.
Set fd = Nothing
End Sub
 
B

BillE

The API seems to work great - i wonder what is the use of the office
filedialog.
Thanks
Bill
 
D

Douglas J. Steele

Many of us wonder the same thing. <g>

I don't know whether they've fixed it in Access 2007, but it was certainly
prone to problems in earlier versions of Access. Not only that, but the
FileSave (which is what you need) didn't work.

Using the API approach is superior because you don't need to set a reference
to use it. Setting the reference is what caused many of the problems: if
your machine was slightly different than the machines of your end users (in
terms of which service packs had been applied), the reference could get
broken, meaning that not only would the dialog stop working, but the entire
application could stop working as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top