![]() |
|
|
|
#1
|
||||
|
||||
|
Here is a concept to read the text into an array of arrays. Source: Function was based on the stellar work of Bob77 on StackOverflow - vb6 - Array and Split commands to create a 2 dimensional array - Stack Overflow Code:
Sub TEST_Get_Properties()
Dim hf As Integer, sFN As String, lines As String
Dim myArray As Variant, iRow As Integer, iCol As Integer
sFN = "C:\Users\" & Environ("UserName") & "\615e8498df6dc933e3baf8732fe5ecf38f4a62b5.txt"
' Load core content using data txt file
hf = FreeFile
Open sFN For Input As #hf
lines = Input$(LOF(hf), #hf)
Close #hf
myArray = SplitSplit(lines)
For iRow = 0 To UBound(myArray)
For iCol = 0 To UBound(myArray(iRow))
Debug.Print "Row:" & iRow, "Col:" & iCol, myArray(iRow)(iCol)
Next
Next
End Sub
Private Function SplitSplit(ByRef Delimited As String, Optional sDiv1 As String = vbLf, Optional sDiv2 As String = " ++ ") As Variant
Dim Rows() As String, AryOfArys As Variant, I As Long
Rows = Split(Delimited, sDiv1)
ReDim AryOfArys(UBound(Rows))
For I = 0 To UBound(Rows)
AryOfArys(I) = Split(Rows(I), sDiv2)
Next
SplitSplit = AryOfArys
End Function
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia Last edited by Guessed; 09-15-2022 at 11:35 PM. |
|
#2
|
|||
|
|||
|
I now recall why I run .txt file in a new Word.application
My .txt files have special characters, including non western (Arabic, Chinese) and I got issues reading .txt files I tried to implement the method here - Solving the Unicode, UTF8, UTF16 and Text Files conundrum in VBA - Francesco Foti's weblog - which read text file as binary and convert special characters but I failed to even run it. Too bad as the code works for all platform (Windows, MAC). Other common method I have found is ADOB.stream with Charset = "utf-8". Txt files seem to be problematic, I am wondering if I am not better consider using .docx instead. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The “spelling and grammar” check fails to work as the number of words in the file exceeds a certain | Jamal NUMAN | Word | 3 | 09-24-2019 10:45 AM |
Need plugin for reading+converting *.pdf file into *.doc
|
pstein | Word | 1 | 05-24-2015 07:05 AM |
| Reading pane on TOP? | hehunt | Outlook | 0 | 04-10-2014 06:34 AM |
How to save a PPT file in 'Reading View' to be opened always in 'Reading View'
|
ItzVickey | PowerPoint | 2 | 08-08-2012 09:23 AM |
Word Basic 2003 to Word Basic 2007 Incompatibility
|
Mark1110 | Word VBA | 1 | 12-29-2010 11:04 PM |