Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transfer Multiple Text Files

0 views
Skip to first unread message

Songoku

unread,
Jan 24, 2005, 5:05:01 AM1/24/05
to
Howdy,

What I am trying to do is import around 30-31 text files in one hit,
currently I have a transfer text for each file. is there a way of importing
all files in one go rather the 30-31 transfer texts macro actions?

Cheers

Steve Schapel

unread,
Jan 24, 2005, 12:16:50 PM1/24/05
to
Songoku,

No, a separate TransferText action is required for each text file.

If you used a VBA procedure instead of a macro, it may be possible to
loop through the files, depending on their file names, and the names of
the tables you are importing into, etc.

--
Steve Schapel, Microsoft Access MVP

Steve Schapel

unread,
Jan 24, 2005, 4:54:53 PM1/24/05
to
Hi Ken,

I can't quite work out how this would work... can you expand?

--
Steve Schapel, Microsoft Access MVP


Ken Snell [MVP] wrote:
> Or use the RepeatMacro action that has a condition based on Dir function?
>

Ken Snell [MVP]

unread,
Jan 24, 2005, 3:43:23 PM1/24/05
to
Or use the RepeatMacro action that has a condition based on Dir function?

--

Ken Snell
<MS ACCESS MVP>

"Steve Schapel" <sch...@mvps.org.ns> wrote in message
news:ua2PBijA...@TK2MSFTNGP10.phx.gbl...

Ken Snell [MVP]

unread,
Jan 24, 2005, 6:51:26 PM1/24/05
to
Hmmm.... this is one of those things that I "saw" in my head in a flash and
didn't think it all the way through < g >.

It would take a bit of finagling...one would need to use a "storage" place
(control on a hidden form, for example) to hold the filename returned by the
Dir function (recursive call or first time call).

OK - new form "HiddenForm" would have one textbox: txtFile.

Something like this?

----
MacroName: MacroStart

Condition: (none)
Action: OpenForm
Form Name: "HiddenForm"

Condition: (none)
Action: SetValue
Expression: Dir("C:\MyFolder\*.txt")
Control Name: Forms!HiddenForm!txtFile

Condition: (none)
Action: RunMacro
Macro Name: MacroGet
Repeat Expression: Len(Forms!HiddenForm!txtFile & "") > 0

(end of MacroStart)

----

MacroName: MacroGet

Action: TransferText
File Name: ="C:\MyFolder| & Forms!HiddenForm!txtFile"
(other arguments as appropriate)

Action: SetValue
Expression: Dir()
Control Name: Forms!HiddenForm!txtFile

--

Ken Snell
<MS ACCESS MVP>

"Steve Schapel" <sch...@mvps.org.ns> wrote in message

news:uHLZZ9lA...@TK2MSFTNGP10.phx.gbl...

Chris Reveille

unread,
Jan 25, 2005, 7:55:24 AM1/25/05
to
You could use code instead of a macro. I got this from a
previous post by Joe Fallon.
How to Import all Files in a Folder:

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII
delimited import.
Dim strfile As String

ChDir ("c:\MyFiles")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "ImportSpecName",
"AccessTableName",
"c:\MyFiles\" & strfile, True
'delete the file (consider moving it to an Archive folder
instead.)
Kill "c:\MyFiles\" & strfile
strfile = Dir
Loop

End Sub

>.
>

Ken Snell [MVP]

unread,
Jan 26, 2005, 2:24:43 PM1/26/05
to
Slight modification:

----
MacroName: MacroStart

Condition: (none)
Action: OpenForm
Form Name: "HiddenForm"

Mode: Hidden

Condition: (none)
Action: SetValue
Expression: Dir("C:\MyFolder\*.txt")
Control Name: Forms!HiddenForm!txtFile

Condition: (none)
Action: RunMacro
Macro Name: MacroGet
Repeat Expression: Len(Forms!HiddenForm!txtFile & "") > 0

Condition: (none)
Action: Close
Object Type: Form
Object Name: HiddenForm


(end of MacroStart)

----

MacroName: MacroGet

Action: TransferText
File Name: ="C:\MyFolder| & Forms!HiddenForm!txtFile"
(other arguments as appropriate)

Action: SetValue
Expression: Dir()
Control Name: Forms!HiddenForm!txtFile


(end of MacroGet)
--

Ken Snell
<MS ACCESS MVP>

"Ken Snell [MVP]" <kthsne...@ncoomcastt.renaetl> wrote in message
news:eo66e%23mAFH...@tk2msftngp13.phx.gbl...

Ken Snell [MVP]

unread,
Feb 12, 2005, 6:45:24 PM2/12/05
to
Just noted a typo in the first action for the MacroGet macro .......

----
MacroName: MacroStart


(end of MacroStart)

----

MacroName: MacroGet


(end of MacroGet)
--

news:e4rVYy9A...@TK2MSFTNGP14.phx.gbl...

0 new messages