我正在使用CADCAM软件并编写宏代码。这是我的基本宏代码。
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
Addtext@ x2#,y2#,0,0,REC$
jump2:
LOOP
CLOSE #1
Clearmarkers@
end@
此代码将正常运行。但它会读取文本并逐行打印。 我需要一次打印读取整个文本文件。
答案 0 :(得分: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