Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 09-15-2022, 05:37 AM
TheBigBoss TheBigBoss is offline Reading basic .txt file fails, how can it be? Windows 7 32bit Reading basic .txt file fails, how can it be? Office 2010 32bit
Advanced Beginner
Reading basic .txt file fails, how can it be?
 
Join Date: Dec 2016
Posts: 56
TheBigBoss is on a distinguished road
Default

All right, here is the function and attached is the txt file with six (6) entries.

So it worked doing a vbLf Split of the text file, followed by a replace of vbCr with vbNullString.
All other combinations failed, I either get that hanging 0 and/or return.
Really strange??

I will mark this post resolved still in a few days


Code:
Sub TEST_Get_Properties()
    Dim hf As Integer: hf = FreeFile
    Dim oD As Object, PropLang As String, PropCat As String, PropNoSymbol As String, _
        ReqEmail As String, ReqID As String, sFE As String, dc(60, 8) As String, _
        i As Integer, lines() As String, tmp2() As String
    sFN = "C:\Users\" & Environ("UserName") & _
            "\615e8498df6dc933e3baf8732fe5ecf38f4a62b5.txt"
    ' Load core content using data txt file
    Open sFN For Input As #hf
    'lines = Split(Input$(LOF(hf), #hf), vbCr)
    'lines = Split(Input$(LOF(hf), #hf), vbCrLf)
    lines = Split(Input$(LOF(hf), #hf), vbLf)
    Close #hf
    For i = 0 To UBound(lines)
        If (Trim(lines(i))) <> "" Then
            ' Needed, to fix a bug
            ' lines(i) = Replace(lines(i), vbCrLf, vbNullString)
            ' lines(i) = Replace(lines(i), vbNewLine, vbNullString)
            ' lines(i) = Replace(lines(i), vbLf, vbNullString)
            lines(i) = Replace(lines(i), vbCr, vbNullString)
            Debug.Print "LINE" & i + 1 & ": " & lines(i) ' Show lines
            tmp2 = Split(lines(i), " ++ ")
            dc(i, 0) = tmp2(0) ' Table no
            dc(i, 1) = tmp2(1) ' Row no
            dc(i, 2) = tmp2(2) ' Cell no
            dc(i, 3) = tmp2(3) ' Data Type
            dc(i, 4) = tmp2(4) ' Content type
            dc(i, 5) = tmp2(5) ' Cell style
            dc(i, 6) = tmp2(6) ' Cell content
        End If
    Next
    ' Write properties
    For i = 0 To UBound(lines)
        Debug.Print "CONTENT" & i + 1 & ": " & dc(i, 6)
        If dc(i, 3) = "Prop" Then
            If dc(i, 4) = "PropLang" Then
                PropLang = dc(i, 6)
                Call WriteProp("Prop-Language", PropLang)
            ElseIf dc(i, 4) = "PropCat" Then
                PropCat = dc(i, 6)
                Call WriteProp("Prop-Category", PropCat)
            ElseIf dc(i, 4) = "PropNoSymbol" Then
                PropNoSymbol = dc(i, 6)
                Call WriteProp("Prop-NoSymbol", PropNoSymbol)
            Else
            End If
        ElseIf dc(i, 3) = "Request" Then
            If dc(i, 4) = "Email" Then
                'PropCat = dc(i, 6)
                Call WriteProp("Prop-ReqEmail", dc(i, 6))
             ElseIf dc(i, 4) = "ID" Then
                'PropCat = dc(i, 6)
                Call WriteProp("Prop-ReqID", dc(i, 6))
            Else
            End If
        Else
        
        End If
    Next
    Debug.Print "Properties set."
    Exit Sub
End Sub
Attached Files
File Type: txt 615e8498df6dc933e3baf8732fe5ecf38f4a62b5.txt (287 Bytes, 6 views)
Reply With Quote
 



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
Reading basic .txt file fails, how can it be? 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
Reading basic .txt file fails, how can it be? 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
Reading basic .txt file fails, how can it be? Word Basic 2003 to Word Basic 2007 Incompatibility Mark1110 Word VBA 1 12-29-2010 11:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft