2017-12-28 6 views
0

Ich benutze CADCAM Software und schreiben Makro-Code. Hier ist mein grundlegender Makrocode.Excel VBA ganze Textdatei auf einmal lesen

OPEN "C:\Area ratio\etch.txt" FOR INPUT as #1 

DO WHILE NOT EOF (1) =1 

LINE INPUT #1, REC$ 
if REC$="" then goto jump2 

'PRINT REC$ 

y2#=Y2#-200 

[email protected] x2#,y2#,0,0,REC$ 
jump2: 
LOOP 

CLOSE #1 

[email protected] 
[email protected] 

Dieser Code funktioniert einwandfrei. aber es liest den Text und druckt Zeile für Zeile. Ich muss lesen ganze Textdatei auf einmal.

Antwort

2
Sub Test() 

    'Tools -> References -> Microsoft Scripting Runtime 
    Dim fso As New FileSystemObject 
    Dim txt As TextStream 
    Dim all_text As String 

    Set txt = fso.OpenTextFile("c:\Temp\textfile.txt") 
    all_text = txt.ReadAll 
    txt.Close 

End Sub 
+0

hi, @JohnyL Es tut mir leid, dass Ihr Code 100% funktioniert in Excel VBA. aber hier benutze ich das Grundmakro. Ich gebe ihnen Ihren Code, aber es zeigt Syntaxfehler. Ich brauche Makrocode –

+0

cool, wenn Sie wissen, dann lassen Sie mich wissen JohnyL –

+0

@ YowE3K Kommentar gelöscht! :) Ich war wirklich verwirrt, bis ich Ausgaben sah. Änderungen zu beobachten ist eine nützliche und coole Sache! :) Frohes neues Jahr! :) – JohnyL

Verwandte Themen