I try to automated import TXT using macro - but i would like the user to be able to select where the TXT file is or brouse.
15 13356
I try to automated import TXT using macro - but i would like the user to be able to select where the TXT file is or brouse.
I did something quite similar in an Access 2003 database, but I don't recall exactly how. It's Saturday afternoon here now, I can check on Monday morning and let you know, if you like.
Hi,
Use TransferText action in Macro. Good luck
Hi,
Use TransferText action in Macro. Good luck
dr PLZ PLZ plz help me to get data from txt file to my access table.
ADezii 8,834
Recognized Expert Expert
I try to automated import TXT using macro - but i would like the user to be able to select where the TXT file is or brouse.
One very neat solution is the use the Microsoft Office FileDialog in conjunction with the TransferText Method. This will give you the complete flexibility that you require. NOTE: You must first set a Reference to the Microsoft Office XX.0 Object Library - Dim fDialog As Office.FileDialog
-
Dim varFile As Variant
-
-
'Set up the File Dialog
-
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
-
With fDialog
-
.AllowMultiSelect = False
-
.Title = "Select a Text File to Import"
-
.InitialFileName = "C:\*.txt"
-
-
'Clear out any Filters, then Add you own (1)
-
.Filters.Add "Text Files", "*.TXT"
-
-
'Show the Dialog. If the Show Method returns True, the User picked
-
'at least 1 File, otherwise the User clicked Cancel
-
If .Show Then
-
For Each varFile In .SelectedItems
-
'There will be only 1 File selected, so place the proper Arguments into the TransferText Method
-
DoCmd.TransferText(TransferType, SpecificationName, TableName, varFile, HasFieldNames, HTMLTableName, CodePage)
-
Next
-
Else 'Nothing selected in File Dialog
-
End If
-
End With
The import code works well excess i get a notify window saying 'You are about to append 1 row(s)' for each record. Has snyone got a suggestion about how to turn this off?
Cheers
in the code type the following near the top ADezii 8,834
Recognized Expert Expert
One very neat solution is the use the Microsoft Office FileDialog in conjunction with the TransferText Method. This will give you the complete flexibility that you require. NOTE: You must first set a Reference to the Microsoft Office XX.0 Object Library - Dim fDialog As Office.FileDialog
-
Dim varFile As Variant
-
-
'Set up the File Dialog
-
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
-
With fDialog
-
.AllowMultiSelect = False
-
.Title = "Select a Text File to Import"
-
.InitialFileName = "C:\*.txt"
-
-
'Clear out any Filters, then Add you own (1)
-
.Filters.Add "Text Files", "*.TXT"
-
-
'Show the Dialog. If the Show Method returns True, the User picked
-
'at least 1 File, otherwise the User clicked Cancel
-
If .Show Then
-
For Each varFile In .SelectedItems
-
'There will be only 1 File selected, so place the proper Arguments into the TransferText Method
-
DoCmd.TransferText(TransferType, SpecificationName, TableName, varFile, HasFieldNames, HTMLTableName, CodePage)
-
Next
-
Else 'Nothing selected in File Dialog
-
End If
-
End With
Reference Line Numbers 4 and 27 - Dim fDialog As Office.FileDialog
-
Dim varFile As Variant
-
-
DoCmd.SetWarnings False
-
-
'Set up the File Dialog
-
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
-
With fDialog
-
.AllowMultiSelect = False
-
.Title = "Select a Text File to Import"
-
.InitialFileName = "C:\*.txt"
-
-
'Clear out any Filters, then Add you own (1)
-
.Filters.Add "Text Files", "*.TXT"
-
-
'Show the Dialog. If the Show Method returns True, the User picked
-
'at least 1 File, otherwise the User clicked Cancel
-
If .Show Then
-
For Each varFile In .SelectedItems
-
'There will be only 1 File selected, so place the proper Arguments into the TransferText Method
-
DoCmd.TransferText(TransferType, SpecificationName, TableName, varFile, HasFieldNames, HTMLTableName, CodePage)
-
Next
-
Else 'Nothing selected in File Dialog
-
End If
-
End With
-
-
DoCmd.SetWarnings True
I would like to do the same thing, but also have limited skills. Is this code for a sub-routine that I can call from a form or a macro?
Thanks,
Frank
ADezii 8,834
Recognized Expert Expert
I would like to do the same thing, but also have limited skills. Is this code for a sub-routine that I can call from a form or a macro?
Thanks,
Frank
You can call it from the Click() Event of a Command Button, Function Procedure, Sub-Routine Procedure, etc.
You can call it from the Click() Event of a Command Button, Function Procedure, Sub-Routine Procedure, etc.
Sorry to be so ignorant, but I've pasted this in to my application as a module.
Is this where it goes?
Thanks,
ADezii 8,834
Recognized Expert Expert
Sorry to be so ignorant, but I've pasted this in to my application as a module.
Is this where it goes?
Thanks,
The easiest solution would be to create a Command Button with the Wizard then copy and Paste this code in the Button's Click() Event.
The easiest solution would be to create a Command Button with the Wizard then copy and Paste this code in the Button's Click() Event.
Thanks, I appreciate your help!
ADezii 8,834
Recognized Expert Expert
Thanks, I appreciate your help!
You are quite welcome.
Hello,
I just started to build my first serious Access Database and need your help.
I use the above method and it is working, but I struggle having a really flexible import and also one for more than one file.
I get the ImportText function only working in a way that I can import a specific file named in the TransferText MEthod as File Name, not the selected one.
Finally I would like to know how to import 12 documents, called VLCV1, VLCV2...
This is what I wanna do.
I have 12 documents with 4 columns that give me
Date, Time, Pressure and Temperature
I need to read these documents in and connect them together to get one document that has
Date, Time, Pressure 1, pressure 2... temp1, temp2
The issue is that those 12 documents exist for different days and I want to keep them separated from each other, by at least selecting the right folder and then import the 12 according files, don't need to have all files always in Access.
I have some more questions, but getting the files into Access with the necessary flexibility is my first target.
Appreciate all help and if further explaination is required, please let me know
ADezii 8,834
Recognized Expert Expert
To process Multiple Text Documents, change Line #9 to:
.
P.S. - You will also need a Method to uniquely Name each Table.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Peter Hansen |
last post by:
The term "mock filesystem" refers to code allowing unit
or acceptance tests to create, read and write, and manipulate
in other ways "virtual" files, without any actual disk
access. Everything is...
|
by: Chris |
last post by:
I've been researching this on and off for weeks, and haven't come up with
anything useful yet. If anyone knows how to do this, please let me know.
From a Java applet running in IE 6.0 using the...
|
by: Dan |
last post by:
Could someone please help me with auto importing a series of data
files into an Access table. I tried to follow code given below in a
previous messagebut i'm getting error messages.
Here's my...
|
by: david |
last post by:
Hi,
I have an MS Access app which is split Front / Back.
The Back End resides on our server. A seperate copy of the front end
also resides on the server, one copy in each of our network users...
|
by: miloann2002 |
last post by:
We have a vendor access package and I am adding query and report modules to
it. An icon was created to display a popup menu to list these report
printing options.
The added queries and reports...
| |
by: Salad |
last post by:
I have a textbox for storing the URL to a web page. I figured the
person could simply copy the URL from IE and paste it into the text box.
The client would like to have a more automated process.
...
|
by: john |
last post by:
I have 400 different Excel-spreadsheetfiles, same structure, all with only
one record in it, and all residing in the same folder. Every now and then
new Excel files are being added. In my Access...
|
by: derfer |
last post by:
I am trying to import a .inf file into access (the file comes from the output of some 3rd party software). I have managed to convert the file by opeing it in notepad and re-saving then a seperate...
|
by: thesti |
last post by:
hello,
how to programmatically from VB .net / php. to import data from an EXCEL file?
is there's no programmatic way, how to automated the process. as i search, the process is:
Simply...
|
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: 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...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |