|
|
 |
BOOK: Excel 2000/2002 VBA Programmer's Reference  | This is the forum to discuss the Wrox book Excel 2000 VBA: Programmers Reference by John Green, Stephen Bullen, Felipe Martins, Brian Johnson; ISBN: 9780764544019 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Excel 2000/2002 VBA Programmer's Reference section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

October 6th, 2006, 04:15 AM
|
|
Registered User
|
|
Join Date: Oct 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Text To Excel then to Access then to Excel
Hi,
I'm a beginner of VBA learner.
Actually i did some programming before this.
Now, i would to try to arrange the contents of my text files
into mc. excel & then procces & then import to mc. access as table & process again & finally export the results in mc. access into mc. excel as final step.
So, first step, i would like to learn how to process those text files into excel.
Can someone guide me on this?
Thanks.
|

May 25th, 2009, 02:17 AM
|
|
Registered User
|
|
Join Date: May 2009
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
open new excel workbook, select Data>Get External Data>Import Text file,
select the text file, then separate every field with a line.
then paste it on a new worksheet. 
gd luck~
|

May 26th, 2009, 03:11 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Location: Wilson, NC, USA
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
First step: You can do this programatically using the following:
Code:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;M:\DownLoads\TestFile.txt", Destination:=Range("A1"))
.Name = "TestFile"
.Refresh BackgroundQuery:=False
End With
|

May 26th, 2009, 03:27 PM
|
|
Authorized User
|
|
Join Date: Jan 2009
Location: Wilson, NC, USA
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
You can also use the code I gave you before to bring in the data then save the file as whatever you want. You can create a table directly in your database to store the data. You can create a delete query to delete out the data. Say you name it "DelDta". Then you can import your new data directly into the table. Your code would work as follows:
Code:
Set dbs = CreateObject("Access.Application")
dbs.OpenCurrentDatabase "C:\Database\MyDatabase.mdb" (Whatever your database name is)
dbs.Visible = True or dbs.visible = false (your preference)
With dbs
dbs.DoCmd.OpenQuery "DelDta", acNormal, acEdit (This is the qry to delete the existing data from the table)
dbs.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"NewData"(This is the name of your table in access),
"C:\TxtHlpr.xls"(this is the name of your file), True, "MyDatadb" (This is the name of the spreadsheet)
End If
dbs.CloseCurrentDatabase
End With
dbs.Quit
You have to ensure that the data in your spreadsheet is formated according to the formats you set up in your table.
Good Luck
S.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |