By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,723 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,723 IT Pros & Developers. It's quick & easy.

Open file with File Dialog

P: n/a
I know how to use the File Dialog control but I'm not sure how to
actually open the file that is selected. Here's my code:

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

'msoFileDialogFilePicker

' Select Excel file for import
With fd
If .Show = True Then
.AllowMultiSelect = False

'Find the selected file name
For Each varFile In .SelectedItems
strFile = varFile
Next
Else
MsgBox "Select a file."
GoTo FindFile_Exit
End If
End With

So once I have the name of the file what do I need to do? Thanks in
advance for the help.

Oct 22 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Ecohouse wrote:
I know how to use the File Dialog control but I'm not sure how to
actually open the file that is selected. Here's my code:

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

'msoFileDialogFilePicker

' Select Excel file for import
With fd
If .Show = True Then
.AllowMultiSelect = False

'Find the selected file name
For Each varFile In .SelectedItems
strFile = varFile
Next
Else
MsgBox "Select a file."
GoTo FindFile_Exit
End If
End With

So once I have the name of the file what do I need to do? Thanks in
advance for the help.
This should get you started
http://www.mvps.org/access/api/api0018.htm
Oct 22 '07 #2

P: n/a
On Oct 22, 4:29 pm, Ecohouse <ecovinda...@yahoo.comwrote:
I know how to use the File Dialog control but I'm not sure how to
actually open the file that is selected. Here's my code:

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

'msoFileDialogFilePicker

' Select Excel file for import
With fd
If .Show = True Then
.AllowMultiSelect = False
I don't API that's why I was using the File Dialog. Do you know what
I need to do to get this working?
>
'Find the selected file name
For Each varFile In .SelectedItems
strFile = varFile
Next
Else
MsgBox "Select a file."
GoTo FindFile_Exit
End If
End With

So once I have the name of the file what do I need to do? Thanks in
advance for the help.

Oct 23 '07 #3

P: n/a
Ecohouse wrote:
On Oct 22, 4:29 pm, Ecohouse <ecovinda...@yahoo.comwrote:
>>I know how to use the File Dialog control but I'm not sure how to
actually open the file that is selected. Here's my code:

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

'msoFileDialogFilePicker

' Select Excel file for import
With fd
If .Show = True Then
.AllowMultiSelect = False

I don't API that's why I was using the File Dialog. Do you know what
I need to do to get this working?

> 'Find the selected file name
For Each varFile In .SelectedItems
strFile = varFile
Next
Else
MsgBox "Select a file."
GoTo FindFile_Exit
End If
End With

So once I have the name of the file what do I need to do? Thanks in
advance for the help.


File/Open (selects file)
http://www.mvps.org/access/api/api0001.htm
EX:
'creates a series of file filters
strFilter = ahtAddFilterItem(strFilter, _
"Microsoft Access Files (*.mdb)", "*.mdb")
strFilter = ahtAddFilterItem("", "Excel Files (*.xls)", "*.xls")
strFilter = ahtAddFilterItem(strFilter, _
"All Files (*.*)", "*.*")
'now get a filename
strFile = GetOpenFile(strFilter:=strFilter)

Run/open file with associated exe
http://www.mvps.org/access/api/api0018.htm
Ex:
If strFile "" THen_
var = fHandleFile(strFile, 3) '3 opens maximized
Oct 23 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.