VB 通过编程命名excel 我想excel的文件名根据日期来命名,但是这样我的程序行不通,麻烦各位大侠看看
OptionExplicitPrivateSubCommand1_Click()DimxlappAsExcel.ApplicationDimxlbookAsExcel.W...
Option Explicit
Private Sub Command1_Click()
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlapp = CreateObject("excel.application")
Set xlbook = xlapp.Workbooks.Add
Set xlsheet = xlbook.Worksheets(2)
xlsheet.Cells(1, 1) = "abcdef"
Dim Sj As Date
Sj = Format(Now, "yyyy-mm-dd")
xlbook.SaveAs FileName:="d:\Sj.xls"
xlbook.Close
xlapp.Quit
Set xlapp = Nothing
End Sub 展开
Private Sub Command1_Click()
Dim xlapp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlapp = CreateObject("excel.application")
Set xlbook = xlapp.Workbooks.Add
Set xlsheet = xlbook.Worksheets(2)
xlsheet.Cells(1, 1) = "abcdef"
Dim Sj As Date
Sj = Format(Now, "yyyy-mm-dd")
xlbook.SaveAs FileName:="d:\Sj.xls"
xlbook.Close
xlapp.Quit
Set xlapp = Nothing
End Sub 展开
2个回答
展开全部
xlbook.SaveAs FileName:="d:\Sj.xls"
把上面这一行修改成下面的:
xlbook.SaveAs FileName:="d:\" & Sj & ".xls"
把上面这一行修改成下面的:
xlbook.SaveAs FileName:="d:\" & Sj & ".xls"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询