如何用VB 把所要写的东西写在excel2007带有宏的工作表里(.xlsm)?

2024-12-23 14:06:30
推荐回答(1个)
回答1:

写成vb标准exe
Private Sub Command1_Click()
Dim xls As Object
Dim book As Object
Dim sht As Object
Set xls = CreateObject("excel.application")
Set book = xls.Workbooks.Open("c:\表格1.xlsm")
Set sht = xls.Worksheets("sheet2")
sht.Cells(2, 2) = "1" 'B2的坐标是第二行第二列
book.Save
book.Close
xls.Quit
End Sub