注册 登录
编程论坛 VB6论坛

谁能帮我看看我这个程序应该加点什么才能保存Excel呢,最好可以帮我写出来,感激不尽!!

孙东东007 发布于 2015-06-13 14:52, 489 次点击
Private Sub Command1_Click()
n = Val(Text5.Text)
d = Val(Text6.Text)
vd = 3.14 / 60 * n * d * 0.1 * 0.1 * 0.1
Text2.Text = vd
If IsNumeric(Text2.Text) = True And Val(Text2.Text) <= 70 Then
 Text2.Text = Round(Val(Text2.Text), 2)
Else: MsgBox "数值不符合"
End If
If Dir("E:\VB程序(千万别动)\excel.bz") = "" Then '
Set xlApp = CreateObject("Excel.Application") '
xlApp.Visible = True '
Set xlBook = xlApp.Workbooks.Open("E:\VB程序(千万别动)\数据.xls") '
Set xlsheet = xlBook.Worksheets(1) '
xlsheet.Activate '
xlsheet.Cells(12, 2) = Val(Text2.Text)
xlBook.RunAutoMacros (xlAutoOpen)
Else
MsgBox ("EXCEL已打开")
End If
If Dir("E:\VB程序(千万别动)\excel.bz") = "" Then
xlBook.RunAutoMacros (xlAutoClose)
xlBook.Close (True)
xlApp.Quit
End If
End Sub
主要就是不能自动保存,跪求~~~着急
4 回复
#2
孙东东0072015-06-13 14:57
大哥,大姐们,我是真不会了,我是菜鸟,别卖关子,就告诉我怎么写进去就行了
#3
wmf20142015-06-14 08:11
这个里面太多了,版主们实在不愿意做重复低效的事,你自己搜搜吧。
#4
中南红叶2015-06-14 09:57
If Dir("E:\VB程序(千万别动)\excel.bz") = "" Then
   Open "地址、格式" For Output As #1
     .
     .
    .
end if
#5
lianyicq2015-06-15 08:44
回复 楼主 孙东东007
确实应该在论坛中多查以前类似贴子

没有保存语句,比如存工作簿
...
Dim WB As Excel.Workbook
...
WB.Save'保存编辑后的文件
...
1