Private Sub Command1_Click()
Dim objExcel As Object
Dim t As String '定义时间变量
Dim p As String '定义文件路径与文件名
Dim s As String '定义表名
'例如你的文件在c:\book1.xls,表为sheet1
t = Time
p = "c:\book1.xls"
s = "sheet1"
Set objExcel = CreateObject("Excel.Application")
Set xlbook = objExcel.Workbooks.Open(p)
Set xlsheet = xlbook.Worksheets(s)
objExcel.Visible = True '设置表可见或不可见
xlsheet.cells(1, 1) = t
Set xlsheet = Nothing
Set xlbook = Nothing
Set objExcel = Nothing
End Sub
用得着么??还是有其它用??
其实你在想要取当前日期的单元格中输入:
=now()
就行了的
Cells(R,C)=date()
=now