Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Notepad or .txt file to excel | Excel Worksheet Functions | |||
Need help converting notepad/txt file to Excel | Excel Discussion (Misc queries) | |||
xl copy cell content to NotePad | Excel Programming | |||
Export notepad file to Excel | Excel Discussion (Misc queries) | |||
Export CSV File, set Windows Read-Only attribute | Excel Programming |