- 积分
- 1281
- 明经币
- 个
- 注册时间
- 2017-8-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2024-4-13 20:36:10
|
显示全部楼层
Public Sub WriteData2ExcelFile()
Dim fn As String
fn = "D:\A.xlsx"
If dir(fn) = vbNullString Then MsgBox fn & vbNewLine & "not found, please check", vbCritical + vbOKOnly: Exit Sub
Dim wb As Workbook, xlapp As excel.Application
Set wb = GetObject(fn)
Set xlapp = wb.Application
wb.ActiveSheet.Range("A1") = VBA.Format(DateTime.Now, "yyyy-mmm-dd,hh:mm:ss")
wb.Windows(1).Visible = True
wb.Close True
If Not (xlapp Is Nothing) Then xlapp.Quit
End Sub
|
|