谁能帮我看一下如何添加关闭Excel进程
我的代码如下:
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
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
...全文
相关推荐
C#彻底关闭Excel进程excel.exe
C#彻底关闭Excel进程excel.exe
vb/vba引用excel无法退出excel进程的解决方法
vb/vba 引用excel对象后通过 xlapp.quit set xlapp=nothing 无法关掉excel进程的解决方法
C#无法关闭Excel进程的解决办法.
C#无法关闭Excel进程的解决办法.转载的.
彻底关闭EXCEL进程
用于彻底关闭EXCEL进程,如有疑问可联系我 QQ群号:6423655 , 可以到www.veege.net下载使用
C# 导出Excel,导出Excel后关闭进程中Excel.exe
特别好的资源,一个有两个例子,都能直接运行,对新手特别有帮助!


VB基础类
