473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

[vba] Getting a filename?

Hey folks -

Working with vba in Access 2k, I'm making a form to automatically import a
spreadsheet. Everything works great when I hardcode the name of the
spreadsheet file; however, I want the user to be able to select the file.

How to I give the user a "select file" dialogue box? All I need to get the
is drive:\path\filename string for the TransferSpreadsheet command.

Thanks!

Steve Lefevre
Nov 12 '05 #1
6 2731
tym
On Thu, 4 Dec 2003 12:33:30 -0500, "Steve Lefevre"
<le********@osu.edu> wrote:

How to I give the user a "select file" dialogue box? All I need to get the
is drive:\path\filename string for the TransferSpreadsheet command.


Put the commonDialogue control on your form and use the .ShowOpen
method.
Tym

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
See http://www.ictis.net/no_spam.html for unsolicited email warning
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
Nov 12 '05 #2
Steve Lefevre wrote:
Hey folks -

Working with vba in Access 2k, I'm making a form to automatically
import a spreadsheet. Everything works great when I hardcode the name
of the spreadsheet file; however, I want the user to be able to
select the file.

How to I give the user a "select file" dialogue box? All I need to
get the is drive:\path\filename string for the TransferSpreadsheet
command.

Thanks!

Steve Lefevre


Do you want to offer them a control that allows them to traverse the file
system? I decided against it given how bad the average user is with
Windows. Also it saved me the hassle of debugging that. I give them a
textbox and tell them to type it in. I save the path in a listbox from
which they can subsequently select.
Nov 12 '05 #3
On Thu, 4 Dec 2003 12:33:30 -0500 in comp.databases.ms-access, "Steve
Lefevre" <le********@osu.edu> wrote:
Hey folks -

Working with vba in Access 2k, I'm making a form to automatically import a
spreadsheet. Everything works great when I hardcode the name of the
spreadsheet file; however, I want the user to be able to select the file.

How to I give the user a "select file" dialogue box? All I need to get the
is drive:\path\filename string for the TransferSpreadsheet command.


http://www.trevor.easynet.co.uk/down...penFileDlg.zip

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #4
"Deano" wrote
Do you want to offer them a control
that allows them to traverse the file
system? I decided against it given how
bad the average user is with
Windows.
Interesting that our experience in this area should differ so vastly. I've
never had users who had any trouble at all using the Windows Common Dialog,
just as in any other application.
Also it saved me the hassle of debugging that.
The code, freely downloadable, from
http://www.mvps.org/access/api/api0001.htm has been used sufficiently that
we know it works. The only debugging needed would be the code that calls it,
and it even includes an example of that. It uses the Windows Common Dialog
API directly, so no ActiveX, etc., has to be distributed.

I give them a textbox and tell them to
type it in. I save the path in a listbox from
which they can subsequently select.


I don't follow how this could be easier for an inexperienced user than
selecting from the Common Dialog; in fact, it seems they'd have to be more
knowledgeable to search for the path and file name, and more prone to
typographical errors entering it.
Nov 12 '05 #5
Larry Linson wrote:
"Deano" wrote
> Do you want to offer them a control
> that allows them to traverse the file
> system? I decided against it given how
> bad the average user is with
> Windows.
Interesting that our experience in this area should differ so vastly.
I've never had users who had any trouble at all using the Windows
Common Dialog, just as in any other application.


I've read one or two articles recently that have cast doubt on any notions
that Windows is actually a positive experience for the end user in terms of
it's basic functions and windowing concepts. i.e users don't really value,
for example, being able to resize and position windows. And that they don't
really find it easy to locate files and data. Heck, even I can't easily
find stuff most of the time. The interface to the filesystem is NOT
intuitive and I make this bold claim since I have had to spend many hours
talking to end users over the phone and visualise them navigating down
dead-ends. This is regardless of whether they were trying to open a file
within an app or just using Windows Explorer. A few people have been
totally amazed when I typed a URL in and a website appeared....("hmm, well
what do you think that court case was about then?").

> Also it saved me the hassle of debugging that.


The code, freely downloadable, from
http://www.mvps.org/access/api/api0001.htm has been used sufficiently
that we know it works. The only debugging needed would be the code
that calls it, and it even includes an example of that. It uses the
Windows Common Dialog API directly, so no ActiveX, etc., has to be
distributed.


Ah, this might make me a convert. Thanks.

> I give them a textbox and tell them to
> type it in. I save the path in a listbox from
> which they can subsequently select.


I don't follow how this could be easier for an inexperienced user than
selecting from the Common Dialog; in fact, it seems they'd have to be
more knowledgeable to search for the path and file name, and more
prone to typographical errors entering it.


That's just how it works for my app; it may indeed be better to have
something more sophisticated at other times.
Nov 12 '05 #6

"Larry Linson" <bo*****@localhost.not> wrote in message
news:ju****************@nwrddc01.gnilink.net...

The code, freely downloadable, from
http://www.mvps.org/access/api/api0001.htm has been used sufficiently that
we know it works. The only debugging needed would be the code that calls it, and it even includes an example of that. It uses the Windows Common Dialog
API directly, so no ActiveX, etc., has to be distributed.

Larry --

Thanks much for your time and expertise.

When I use the example, I get errors on ahtAddFilterItem and
ahtCommonFileOpenSave. Specifically "Compile Error: Sub or Function not
defined". Am I missing a reference or something?

This is the code I've included:

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bobby | last post by:
Hello, I'm seeing strange behavior experimenting with calling .NET. If I create a project in .NET 2k3 and select 'interop assembly' it will create the CCW for me, correct? I created a class...
1
by: Bobby | last post by:
Hello, I'm seeing strange behavior experimenting with calling .NET. If I create a project in .NET 2k3 and select 'interop assembly' it will create the CCW for me, correct? I created a class...
6
by: rlntemp-gng | last post by:
I need to extract information from some Excel files but am stuck with part of it: As an example, I have the following Excel File that has 3 tabbed sheets: FileName: ...
7
by: NeverLift | last post by:
This is probably answered elsewhere, but I've searched the Web and VBA for Excel manual, find no answers. I have a VBA-coded macro in an Excel workbook that is to open another existing workbook --...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.