Open file with File Dialog
am 22.10.2007 22:29:40 von Ecohouse
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.
Re: Open file with File Dialog
am 22.10.2007 22:52:49 von Salad
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
Re: Open file with File Dialog
am 23.10.2007 14:20:44 von Ecohouse
On Oct 22, 4:29 pm, 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
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.
Re: Open file with File Dialog
am 23.10.2007 16:04:29 von Salad
Ecohouse wrote:
> On Oct 22, 4:29 pm, 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
>
> 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