|
本帖最后由 ★江★--婞諨 于 2013-1-6 20:22 编辑
下面这段代码可以把表格以时间命名另存为,我想让它以“A1"单元格里面的文本命名另存,请问如何修改,小弟先谢谢了.
Private Sub CommandButton1_Click()
On Error Resume Next ''此句必须有,防止无EXCEL进程时GetObject出错退出
Dim objExcelAPP, xlbook, xlsname, isOpen
xlsname = "D:\职工评级建档\职工建档空白样表.xls" ''Excel文档路径
Set objExcelAPP = GetObject(, "Excel.Application") ''获取当前运行的Excel应用程序对象
objExcelAPP.Visible = True
If TypeName(objExcelAPP) = "Application" Then ''Excel已打开,遍历工作薄查找对应文档是否已打开
For Each xlbook In objExcelAPP.Workbooks
If xlbook.FullName = xlsname Then
isOpen = True
Exit For
End If
Next
End If
If isOpen Then
xlbook.SaveAs "D:\职工评级建档\" & Date & "_" & Hour(Now) & "_" & Minute(Now) & "_" & Second(Now) & ".xls" (主要是这里怎么改)
Else
MsgBox "文件没有打开!"
End If
objExcelAPP.Quit
Set objExcelAPP = Nothing
End Sub
|
|