谁能帮我看一下如何添加关闭Excel进程

goosen goosen 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的代码如下:


Private Sub Command1_Click()
Dim i As Integer, j As Integer, G As Integer
Dim fn As Long, strT As String, arr() As String
For i = 0 To File1.ListCount - 1
fn = FreeFile
Open File1.Path & "\" & File1.List(i) For Input As #fn
For j = 1 To 3
Line Input #fn, strT
Next j
arr = Split(strT, ",")
sh.cells(1, 1) = "线路名"
sh.cells(1, 2) = "导线长度"
sh.cells(1, 3) = "Fb"
sh.cells(1, 4) = "Fb(max)"
sh.cells(1, 5) = "相对闭合差"
sh.cells(1, 6) = "站数"
sh.cells(i + 2, 1) = arr(7)
sh.cells(i + 2, 2) = arr(4)
sh.cells(i + 2, 3) = arr(0)
sh.cells(i + 2, 4) = arr(1)
sh.cells(i + 2, 5) = arr(6)
G = 0
Do Until EOF(1)
Line Input #fn, strT
G = G + 1
Loop

Close #fn
sh.cells(i + 2, 6) = G
Next i
ex.Visible = True

End Sub

Private Sub Command2_Click()
Dim i As Integer, j As Integer
Dim fn As Long, strT As String, arr() As String
For i = 0 To File1.ListCount - 1
fn = FreeFile
Open File1.Path & "\" & File1.List(i) For Input As #fn
For j = 1 To 2
Line Input #fn, strT
Next j
arr = Split(strT, ",")
sh.cells(1, 1) = "线路名"
sh.cells(1, 2) = "导线长度"
sh.cells(1, 3) = "∑b"
sh.cells(i + 2, 1) = arr(0)
For j = 1 To 1
Line Input #fn, strT
Next j
Close #fn
arr = Split(strT, ",")
sh.cells(i + 2, 2) = arr(1)
sh.cells(i + 2, 3) = arr(3)
Next i
ex.Visible = True


End Sub


Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub Form_Load()
File1.Pattern = "g*.txt;z*.txt;1-printhighf-g*.txt;1-printhighf-z*.txt"
Set ex = CreateObject("Excel.Application")
Set wb = ex.workbooks.Add
Set sh = wb.Sheets(1)
End Sub
...全文
评论 12
收藏 已收藏
分享
返回顶部
goosen
VB基础类 7,788 成员 197,583 内容