469,644 Members | 1,978 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,644 developers. It's quick & easy.

Open file with File Dialog

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
3 8050
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
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
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.

Similar topics

4 posts views Thread by John | last post: by
2 posts views Thread by Jonathan Trevor | last post: by
reply views Thread by Dune | last post: by
5 posts views Thread by charles | last post: by
7 posts views Thread by Peter | last post: by
5 posts views Thread by Stefano Tonello | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.