Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default read windows notepad file content into excel?

Greetings
I have many notepad files that i pick through manually and copy/paste info
out to excel. The notepad file content is logically structured ('bananas =
yellow' in file1, 'bananas = green' in file2 etc. sort of thing). Is it
possible for an excel macro to retrieve external file content like this?
Many Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default read windows notepad file content into excel?


Two methods:

'Method 1.
Public Sub ImportTextFile1()
Dim txtFile, txtTemp, FileContents As String
Dim fileNum As Integer
txtFile = "C:\SAMPLE.txt"
FileContents = vbNullString
txtTemp = vbNullString
fileNum = FreeFile()
Open txtFile For Input As #fileNum
Do While Seek(fileNum) <= LOF(fileNum)
Line Input #fileNum, txtTemp
FileContents = FileContents & txtTemp & vbCrLf
Loop
Close #fileNum
MsgBox FileContents
End Sub

'Method 2.
Public Sub ImportTextFile2()
Dim fso, f
Dim FileContents As String
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\SAMPLE.txt")
FileContents = f.ReadAll
f.Close
MsgBox FileContents
End Sub



"David" schreef in bericht
...
Greetings
I have many notepad files that i pick through manually and copy/paste info
out to excel. The notepad file content is logically structured ('bananas =
yellow' in file1, 'bananas = green' in file2 etc. sort of thing). Is it
possible for an excel macro to retrieve external file content like this?
Many Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default read windows notepad file content into excel?

David,
Excel can open text files with the Text Import wizard.
Just open your file from FileOpen and follow the steps. I imagine you need
to set the "Delimited" option, then specify the Delimiter "Other" to "=".
If you record a macro whilst do this, you will get the code.

NickHK

"David" wrote in message
...
Greetings
I have many notepad files that i pick through manually and copy/paste info
out to excel. The notepad file content is logically structured ('bananas =
yellow' in file1, 'bananas = green' in file2 etc. sort of thing). Is it
possible for an excel macro to retrieve external file content like this?
Many Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Notepad or .txt file to excel nathan Excel Worksheet Functions 3 December 1st 09 09:44 PM
Need help converting notepad/txt file to Excel QuestionMan Excel Discussion (Misc queries) 0 February 8th 08 03:41 PM
xl copy cell content to NotePad elrussell[_6_] Excel Programming 9 April 16th 06 04:23 PM
Export notepad file to Excel Carrie Excel Discussion (Misc queries) 2 February 2nd 06 05:36 PM
Export CSV File, set Windows Read-Only attribute InNeedOfHelp! Excel Programming 1 January 27th 05 07:31 PM


All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"