如何用VB把txt文件指定内容写到EXCEL中
1个回答
展开全部
又没有一点悬赏分,又匿名,唉。看在完成任务的份上,我也就勉为其难吧。
Dim
exlApp
As
Excel.Application
Dim
exlBook
As
Excel.Workbook
Dim
Str
As
String,
I
As
Integer
Open
App.Path
&
"\test.txt"
For
Input
As
#1
Set
exlApp
=
New
Excel.Application
exlApp.Visible
=
True
Set
exlBook
=
exlApp.Workbooks.Open(App.Path
+
"\test.xls")
'打开已有Excel文件
'向Excel表中写入数据,Sheets(1)为第1个工作表,Cells(行号,列号)是单元格
I
=
0
While
Not
EOF(1)
Line
Input
#1,
Str
I
=
I
+
1
exlApp.Sheets(1).Cells(I,
1)
=
Str
Wend
Close
#1
'关闭文本文件
exlBook.Close
'关闭
工作簿
exlApp.Quit
'关闭Excel
Dim
exlApp
As
Excel.Application
Dim
exlBook
As
Excel.Workbook
Dim
Str
As
String,
I
As
Integer
Open
App.Path
&
"\test.txt"
For
Input
As
#1
Set
exlApp
=
New
Excel.Application
exlApp.Visible
=
True
Set
exlBook
=
exlApp.Workbooks.Open(App.Path
+
"\test.xls")
'打开已有Excel文件
'向Excel表中写入数据,Sheets(1)为第1个工作表,Cells(行号,列号)是单元格
I
=
0
While
Not
EOF(1)
Line
Input
#1,
Str
I
=
I
+
1
exlApp.Sheets(1).Cells(I,
1)
=
Str
Wend
Close
#1
'关闭文本文件
exlBook.Close
'关闭
工作簿
exlApp.Quit
'关闭Excel
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |