Wrox Programmer Forums
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2006, 03:15 AM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.



 
Old May 25th, 2009, 01:17 AM
Registered User
 
Join Date: May 2009
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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~
 
Old May 26th, 2009, 02:11 PM
Authorized User
 
Join Date: Jan 2009
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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
 
Old May 26th, 2009, 02:27 PM
Authorized User
 
Join Date: Jan 2009
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Smile

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert text from excel to proper date in access bprodman Access VBA 1 June 18th, 2007 03:48 PM
Importing text file into excel anamarijaf Excel VBA 4 January 27th, 2007 05:50 AM
Converting excel data to Access using excel VBA ShaileshShinde VB Databases Basics 1 April 26th, 2006 07:57 AM
Excel IMport Text Help!! money Excel VBA 2 April 30th, 2004 12:43 AM
Excel in win 2000 to excel winxp (excel 2002) Max Excel VBA 3 August 28th, 2003 04:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.