Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 19th, 2004, 01:28 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert data in a text file and export them

Hi for all
This is very hard.
I want to insert into a text file create by Excel some information like name, address and so on.
When the file is opened, excel´s macro waits 'till I save the file.
Then, it copy each line of the text file and put in a excel´s row.
Please HELP MEEEEEEE!!

Hughes for all


Alex

Reply With Quote
  #2 (permalink)  
Old January 19th, 2004, 01:47 PM
Authorized User
 
Join Date: Dec 2003
Location: Middletown, CT, USA.
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If it is waiting for a 'save' to occur then the macro has that request coded into it...You will need to edit the macro. I am unclear as to what your final goal is...are you trying to write several records into an excel spreadsheet or take excel information and put it into a word (or other text) document.

John

Reply With Quote
  #3 (permalink)  
Old January 23rd, 2004, 07:28 AM
Authorized User
 
Join Date: Jul 2003
Location: Reading, Berkshire, United Kingdom.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alex_read
Default

If I understand this correctly, you want to read the text of a text file and place each line of it's text into a row in an Excel worksheet?

If so here's the code to accomplish this (just change the filename from boot.ini):

Private Sub CommandButton1_Click()
    Dim intLoopCounter As Integer
    Dim strTemp As String

    intLoopCounter = 1

    Open "C:\boot.ini" For Input As #1

        Do Until EOF(1)
            Line Input #1, strTemp

            Cells(intLoopCounter, 1) = strTemp
            intLoopCounter = intLoopCounter + 1
        Loop

    Close #1
End Sub


Reply With Quote
  #4 (permalink)  
Old January 23rd, 2004, 07:31 AM
Authorized User
 
Join Date: Jul 2003
Location: Reading, Berkshire, United Kingdom.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alex_read
Default

The first part of this (taking each line/row's text from Excel & placing this INTO a text file), can be accomplished by using this:

Private Sub CommandButton1_Click()
    Dim intLoopCounter As Integer
    Dim strTemp As String

    For intLoopCounter = 1 To UsedRange.Rows.Count
        strTemp = strTemp & Cells(intLoopCounter, 1) & vbCrLf
    Next intLoopCounter

    Open "C:\boot1.ini" For Output As #1
        Print #1, strTemp
    Close #1
End Sub

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert a new line at beginning of text file? how? Satorikin VB.NET 2002/2003 Basics 8 October 15th, 2008 09:55 PM
Most efficient way to insert text into a file StumblingInTheDark Visual Basic 2005 Basics 1 February 22nd, 2007 01:09 PM
Export to text file without exponents Pavesa Access 14 November 24th, 2004 07:44 AM
DTS text file export - Batch Process Tim Barbour SQL Server DTS 1 November 23rd, 2004 11:50 AM
how can I insert a new line at top of text file? Satorikin VB.NET 1 March 4th, 2004 03:41 AM



All times are GMT -4. The time now is 03:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.