kwhw.net
当前位置:首页 >> vBA 读取txt文件 >>

vBA 读取txt文件

Private Sub Command1_Click() Dim txt As String Open "C:\AAA.TXT" For Input As #1 Do While Not EOF(1) Line Input #1, txt MsgBox txt Loop Close #1 End Sub

open "c:\test.txt" for input as #1 do while not eof(1) line input #1,tmp list1.additem tmp loop close #1

Dim num As Integer Dim r As String Dim f As String '将f指定为你的文件的路径 f = "t.txt" num = FreeFile() Open f For Input As num While Not EOF(num) Line Input #num, r MsgBox (r) Wend

Private Sub CommandButton1_Click()Dim filename, inputstring As StringDim i As IntegerDim datai = 1filename = "d:\WYKS.txt" '本列TXT文件放在D盘中Open filename For Input Access Read As #1Do While Not EOF(1)Line Input #1, inputstr...

open打开文件需要有个完全的路径名称, 建议先使用GetOpenFilename获取需要打开的文件全名称. 再使用open进行文件流操作. dim count as long Dim Filt As String Dim FilterIndex As Integer Dim Title As String Dim File As Variant Dim fText ...

dim i as,s() interage Open "你的文件路径" For Input As #1 Do Until EOF(1) s(i++)=Input #1,name,id,score '姓名,学号,成绩 Loop for k=0 to i print s(i) ok

Sub test() Dim starRng As Range Set starRng = Sheet1.Range("B5") '要输入的第一个单元格 Dim txtPath As String, nextLine As String txtPath = ThisWorkbook.Path & "\temp.txt" 'txt所在的目录 Open txtPath For Input As #1 Do While Not...

Sub 宏1() Dim a As String Dim fname As String Dim fname2 As String fname = "d:\123\123.txt" fname2 = "d:\123\124.txt" Open fname For Input As #1 Open fname2 For Output As #2 On Error Resume Next Do Input #1, a Print #2, a Loop ...

用vba去遍历,提取文件名。资料如下供参考 http://club.excelhome.net/thread-1258425-1-1.html 提取txt文件内容,可以通过vba处理

网站首页 | 网站地图
All rights reserved Powered by www.kwhw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com