Group:  Microsoft Access ยป microsoft.public.access.externaldata
Thread: select file dialog box for dummies pls

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

select file dialog box for dummies pls
"Iona" <hmcgregor[ at ]internode.on.net> 13.07.2006 02:45:39
Hi, ok i've been checking out the howto 'open file dialog box' posts,
and have checked out the api, howeve i'm stymed on how to actually use
the code, yes you paste it into a new module, but then what, how do you
call this from form button. Sorry if this is a bit basic, but I've only
been doing this for two weeks now, its all rather new, any pointers
would be appreciated.

kind regards
iona

RE: select file dialog box for dummies pls
Klatuu 13.07.2006 13:09:02
There is a function in the module named Testit. You can use that to see how
it works. Also, here is an example of how I have used it:

'Set up default path and file
strDefaultDir = "\\rsltx1-bm01\busmgmt\Vought " & strCurrYear & "\" &
strCurrYear _
& " Actuals\" & strCurrMonth & "\FFP Charts\"
strDefaultFileName = Me.cboOffering & " Summary " &
Me.cboPeriod.Column(1) _
& " " & Me.txtCurrYear & ".xls"
'Set filter to show only Excel spreadsheets
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)")
'Flags Hides the Read Only Check and Only allow existing files
lngFlags = ahtOFN_HIDEREADONLY Or ahtOFN_OVERWRITEPROMPT
'Call the Open File Dialog
varGetFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
InitialDir:=strDefaultDir, _
Filter:=strFilter, _
Filename:=strDefaultFileName, _
Flags:=lngFlags, _
DialogTitle:="Save Report")
If varGetFileName <> "" Then
xlBook.SaveAs Filename:=varGetFileName
End If


"Iona" wrote:

[Quoted Text]
> Hi, ok i've been checking out the howto 'open file dialog box' posts,
> and have checked out the api, howeve i'm stymed on how to actually use
> the code, yes you paste it into a new module, but then what, how do you
> call this from form button. Sorry if this is a bit basic, but I've only
> been doing this for two weeks now, its all rather new, any pointers
> would be appreciated.
>
> kind regards
> iona
>
>
Re: select file dialog box for dummies pls
"Iona" <hmcgregor[ at ]internode.on.net> 13.07.2006 23:00:54
Hi and thankyou, now i know this sounds really basic, but how do i
call(?) this from a command button on a form.. Do i cut and paste the
below into a private sub button_click
code? Sorry about this, I've only started doing this stuff two weeks
ago, so I still get a bit mystified.

cheers
Honor


Klatuu wrote:
[Quoted Text]
> There is a function in the module named Testit. You can use that to see how
> it works. Also, here is an example of how I have used it:
>
> 'Set up default path and file
> strDefaultDir = "\\rsltx1-bm01\busmgmt\Vought " & strCurrYear & "\" &
> strCurrYear _
> & " Actuals\" & strCurrMonth & "\FFP Charts\"
> strDefaultFileName = Me.cboOffering & " Summary " &
> Me.cboPeriod.Column(1) _
> & " " & Me.txtCurrYear & ".xls"
> 'Set filter to show only Excel spreadsheets
> strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)")
> 'Flags Hides the Read Only Check and Only allow existing files
> lngFlags = ahtOFN_HIDEREADONLY Or ahtOFN_OVERWRITEPROMPT
> 'Call the Open File Dialog
> varGetFileName = ahtCommonFileOpenSave( _
> OpenFile:=False, _
> InitialDir:=strDefaultDir, _
> Filter:=strFilter, _
> Filename:=strDefaultFileName, _
> Flags:=lngFlags, _
> DialogTitle:="Save Report")
> If varGetFileName <> "" Then
> xlBook.SaveAs Filename:=varGetFileName
> End If
>
>
> "Iona" wrote:
>
> > Hi, ok i've been checking out the howto 'open file dialog box' posts,
> > and have checked out the api, howeve i'm stymed on how to actually use
> > the code, yes you paste it into a new module, but then what, how do you
> > call this from form button. Sorry if this is a bit basic, but I've only
> > been doing this for two weeks now, its all rather new, any pointers
> > would be appreciated.
> >
> > kind regards
> > iona
> >
> >

Re: select file dialog box for dummies pls
Klatuu 14.07.2006 12:58:02
You can call it from the Click event of a command button. Much of the code I
posted is specific to what I need in my application. For example, setting up
the default directory, file type selection, default file name, etc. Here Is
the generic part with some explanation:

The only part that is required to generate the dialog and get a value
returned is:
varGetFileName = ahtCommonFileOpenSave
The above line will return the path and file chosen by the user.
It will show whatever directory is your current directory. It will have no
file types specified. The title will always be Open and the command buttons
will be Open and Cancel.

If we want to present the user with a Save dialog, we add the OpenFile
argument:
varGetFileName = ahtCommonFileOpenSave(OpenFile := False)
This does nothing more than change the title to Save As and the first
command button to Save.

It is important to note that this or any other parameters passed has any
effect on the return value of the function. All it does it return a path and
file. What you do with it is up to you.

You can also change what is in the title with this argument.
varGetFileName = ahtCommonFileOpenSave(DialogTitle:="Save Report")
Now the command button will say Open, but the title will be Save Report.
The following version will make the title Save Report and the command button
say Save

varGetFileName = ahtCommonFileOpenSave(OpenFile := False,
DialogTitle:="Save Report")

Anyway, I think you get the drift. Also, be sure to check for a zero length
string being returned. That means the user clicked Cancel or closed the
Dialog.

Good Luck.


Note I am using a variant. It could be a string variable, but the old
ActiveX control required a variant and I did not change the data types when I
adapted my code to use the API.


[Quoted Text]
> > varGetFileName = ahtCommonFileOpenSave( _
> > OpenFile:=False, _
> > InitialDir:=strDefaultDir, _
> > Filter:=strFilter, _
> > Filename:=strDefaultFileName, _
> > Flags:=lngFlags, _
> > DialogTitle:="Save Report")



"Iona" wrote:

> Hi and thankyou, now i know this sounds really basic, but how do i
> call(?) this from a command button on a form.. Do i cut and paste the
> below into a private sub button_click
> code? Sorry about this, I've only started doing this stuff two weeks
> ago, so I still get a bit mystified.
>
> cheers
> Honor
>
>
> Klatuu wrote:
> > There is a function in the module named Testit. You can use that to see how
> > it works. Also, here is an example of how I have used it:
> >
> > 'Set up default path and file
> > strDefaultDir = "\\rsltx1-bm01\busmgmt\Vought " & strCurrYear & "\" &
> > strCurrYear _
> > & " Actuals\" & strCurrMonth & "\FFP Charts\"
> > strDefaultFileName = Me.cboOffering & " Summary " &
> > Me.cboPeriod.Column(1) _
> > & " " & Me.txtCurrYear & ".xls"
> > 'Set filter to show only Excel spreadsheets
> > strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)")
> > 'Flags Hides the Read Only Check and Only allow existing files
> > lngFlags = ahtOFN_HIDEREADONLY Or ahtOFN_OVERWRITEPROMPT
> > 'Call the Open File Dialog
> > varGetFileName = ahtCommonFileOpenSave( _
> > OpenFile:=False, _
> > InitialDir:=strDefaultDir, _
> > Filter:=strFilter, _
> > Filename:=strDefaultFileName, _
> > Flags:=lngFlags, _
> > DialogTitle:="Save Report")
> > If varGetFileName <> "" Then
> > xlBook.SaveAs Filename:=varGetFileName
> > End If
> >
> >
> > "Iona" wrote:
> >
> > > Hi, ok i've been checking out the howto 'open file dialog box' posts,
> > > and have checked out the api, howeve i'm stymed on how to actually use
> > > the code, yes you paste it into a new module, but then what, how do you
> > > call this from form button. Sorry if this is a bit basic, but I've only
> > > been doing this for two weeks now, its all rather new, any pointers
> > > would be appreciated.
> > >
> > > kind regards
> > > iona
> > >
> > >
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net