473,396 Members | 2,158 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,396 software developers and data experts.

Import Excel spreadsheet with user-chosen file

Is it possible to use the TransferSpreadsheet function without hardcoding in the filename? I'm working on a DB that will have 10-15 people using daily and I'd like to have an import function where they can click a button, a dialog box opens asking them to select the file to import, then have it import the users and append to an existing table. I have it working with the file and path coded into the function call, but I'd like to have the flexibility of letting the users choose the file location if it's not too much work.
Jul 28 '11 #1
2 2350
gnawoncents
214 100+
Check out the Access Help topic for FileDialog Object. That should get you to where you want.
Jul 28 '11 #2
NeoPa
32,556 Expert Mod 16PB
This might help to get you started.

First off, for this approach you need a reference to "MS VBA Extensibility" (of whatever appropriate version).

The following routine does most of the main work for you :
Expand|Select|Wrap|Line Numbers
  1. 'FSBrowse (File System Browse) allows the operator to browse for a file/folder.
  2. Public Function FSBrowse(Optional strStart As String = "", _
  3.                          Optional lngType As MsoFileDialogType = _
  4.                              msoFileDialogFolderPicker) As String
  5.     FSBrowse = ""
  6.     With Application.FileDialog(dialogType:=lngType)
  7.         .Title = "Browse for "
  8.         Select Case lngType
  9.         Case msoFileDialogOpen
  10.             .Title = .Title & "File to open"
  11.         Case msoFileDialogSaveAs
  12.             .Title = .Title & "File to SaveAs"
  13.         Case msoFileDialogFilePicker
  14.             .Title = .Title & "File"
  15.         Case msoFileDialogFolderPicker
  16.             .Title = .Title & "Folder"
  17.         End Select
  18.         .InitialFileName = strStart
  19.         .AllowMultiSelect = False
  20.         .InitialView = msoFileDialogViewDetails
  21.         If .Show Then FSBrowse = .SelectedItems(1)
  22.     End With
  23. End Function
The following routine behind a Command Button (cmdFolder in this case) is an example of how you can call this. I store the value in lblFolder.Caption hence its use as a parameter to the call :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdFolder_Click()
  2.     Dim strPath As String
  3.  
  4.     strPath = FSBrowse(Me.lblFolder.Caption)
  5.     If strPath > "" Then _
  6.         Me.lblFolder.Caption = Replace(strPath & "\", "\\", "\")
  7. End Sub
Jul 28 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
0
by: jere7 | last post by:
I have read through pages of responses and perhaps I missed a solution... but here is my issue: I have setup a Access database to track sales for our company and want to send out a shell Excel...
5
by: Colleyville Alan | last post by:
I need to import a spreadsheet into an Access table. The spreadsheet has performance for mutual funds for various periods. The problem is that if there is no info for a particular period, the...
0
by: Aravind | last post by:
Hi folks. My project has 2 tables: tblBook - ISBN , Title, Author, Year, Publisher, Total tblAcc - AccNo , ISBN , Status (combo box), Borrow (check box) Example: tblBook 013089592X | ......
4
by: john andrew | last post by:
-- hello In VB.net can I import an excel spreadsheet into a formand display it. Also edit/save cells also on the form. I want to use code in VB.net form that also effect the spreadsheet....
5
by: Uma Muthu | last post by:
Hi, I have an ASP.NET (2.0) webform. I want to import an excel spreadsheet. In that Excel spreadsheet are specific cells that I want to capture specific data from. Is it doable? Thanks, ...
6
by: jalmar | last post by:
Hello again: My second question is: I am linking an excel spreadsheet into Access, I have it linked and at first had problems getting the information imported into Access-it wasn't importing-I...
1
by: mforema | last post by:
Hi Everybody, I have an Access table with a field filled with outdated hyperlinks. I also have an excel spreadsheet that is the master list for these hyperlinks. The spreadsheet will be updated...
2
by: moses40 | last post by:
I need help importing an excel spreadsheet into an existing access table using vba. However I have a few requirements. 1. It needs to prompt the user to specify where the spreadsheet is 2. It needs...
3
by: Teresa Barnacle | last post by:
Hi Need a little help or advice. I have a DBase with 2 tables a. Candidate Personal Details b. Candidate Registration Detail (reg for a qualification) A customer fills out a excel...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.