[AccessD] Importing multiple txt files

Max Wanadoo max.wanadoo at gmail.com
Wed Apr 1 13:26:05 CDT 2009


William, given what Jim has just said. Have you got your Reference correct.
You need the reference to MS Office for the version you are using.

Max



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hewson, Jim 
Sent: 01 April 2009 19:20
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Importing multiple txt files

Yes.
I created it in 2000 then moved to 2003 and used it in 2007 runtime.
Not a problem.  

Jim


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William
Hindman
Sent: Wednesday, April 01, 2009 1:07 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Importing multiple txt files

Jim

...have you gotten the FileDialog to work in a runtime?
...I'd love to use it but so far no go.

William

--------------------------------------------------
From: "Hewson, Jim " <JHewson at nciinc.com>
Sent: Wednesday, April 01, 2009 1:29 PM
To: "Access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] Importing multiple txt files

> Below is what I've used in the past and it works well.
> The User can select one or any number of files (using the ctl or shift
> keys) in the directory.
> This will actually place the file names with the perspective
directories
> into a list box.  You should be able to get what you need from this.
>
> Private Sub btnSelectFiles_Click()
>    Dim fDialog As Office.FileDialog
>    Dim varFile As Variant
>    Dim txtFile As String
>
>    Dim strImportFile As String
>
>    'Clear Textbox contents.
>    Me.lstImportFile.RowSource = ""
>
>   'Set up the File Dialog
>   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
>   With fDialog
>      'Allow user to select one file in dialog box
>      .AllowMultiSelect = True
>
>      'Set the title of the dialog box.
>      .Title = "Please select ALL files"
>
>      'Clear out the current filters, and add our own.
>      .Filters.Clear
>      .Filters.Add "Excel Workbooks 2000-2003", "*.xls"
>      .Filters.Add "Excel Workbooks 2007", "*.xlsx"
>
>      'Show the dialog box. If the .Show method returns True, the
>      'user picks one file. If the .Show method returns
>      'False, the user clicked Cancel.
>
>      If .Show = True Then
>        For Each varFile In .SelectedItems
>            Me.lstImportFile.AddItem varFile
>            txtFile = varFile
>        Next
>
>      Else
>         MsgBox "You clicked Cancel in the file dialog box.", vbOKOnly,
> "Cancelled"
>      End If
>      .InitialFileName = ""
>    End With
>    Set fDialog = Nothing
>    Set varFile = Nothing
>
>    strImportFile = Me.lstImportFile.RowSource
>
> End Sub
>
> Jim
>
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Janet
Erbach
> Sent: Wednesday, April 01, 2009 12:24 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] Importing multiple txt files
>
> I planned on allowing the user to navigate to select the directory.
>
> Janet
>
> On Wed, Apr 1, 2009 at 12:21 PM, Hewson, Jim <JHewson at nciinc.com>
wrote:
>
>> Janet,
>> Will the files always reside in the same directory or will the user
be
>> able to select the directory?
>>
>> Jim
>>
>>
>> -----Original Message-----
>> From: accessd-bounces at databaseadvisors.com
>> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Janet
> Erbach
>> Sent: Wednesday, April 01, 2009 12:12 PM
>> To: accessd at databaseadvisors.com
>> Subject: [AccessD] Importing multiple txt files
>>
>> Hello!
>>
>> I would like to programmatically import one by one all the text files
> in
>> a
>> given directory - usually around 30 files.  I've used code that I
> copied
>> from http://www.mvps.org/access/api/api0001.htm to allow the user to
>> browse
>> through windows directories and select a single file to process...but
>> now I
>> want to process ALL the files in a given directory, regardless of the
>> number
>> of files.  I assumed I would build an array with the names of all the
>> files
>> and then loop through that array in my code to import and process
them
>> one
>> by one.
>>
>> Does anyone know of code I could utilize that would allow me to
>> identifity
>> the names of all the txt files in a selected directory?  I'm lost
when
>> it
>> comes to interfacing Access with Windows in this way!
>>
>> Janet Erbach
>> NaturalHealthyConcepts.com
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
>>
>
########################################################################
> ########
>> If you have received this message in error, please contact the sender
>> immediately and be aware that the use, copying, or dissemination of
>> this information is prohibited. This email transmission contains
>> information from NCI Information Systems, Inc. that may be considered
>> privileged or confidential and is intended solely for the named
>> recipient.
>>
>>
>
########################################################################
> ########
>>
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
########################################################################
########
> If you have received this message in error, please contact the sender
> immediately and be aware that the use, copying, or dissemination of
> this information is prohibited. This email transmission contains
> information from NCI Information Systems, Inc. that may be considered
> privileged or confidential and is intended solely for the named
> recipient.
>
########################################################################
########
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
############################################################################
####
If you have received this message in error, please contact the sender
immediately and be aware that the use, copying, or dissemination of 
this information is prohibited. This email transmission contains 
information from NCI Information Systems, Inc. that may be considered 
privileged or confidential and is intended solely for the named 
recipient.
############################################################################
####

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list