'4.6.1 根据需求创建工作薄
Sub WbAdd()
'程序创建""工作薄,保存到本文件所在的目录中
Dim Wb As Workbook, sht As Worksheet
'新建一个工作薄,并将其赋给变量Wb
Set Wb = Workbooks.Add
Set sht = Wb.Worksheets(1)
With sht
'修改第一张工作表的标签名称
.Name = "花名册"
'设置表头
.Range("A1:F1")=Array("序号","姓名","性别","出生年月","参加工作时间","备注")
End With
'保存新建的工作薄到指定的目录中
'保存到共享文件夹中Wb.SaveAs "\\ALVINREN\Users\aren\Desktop\New folder" & "\namelist.xlsx"
Wb.SaveAs ThisWorkbook.Path & "\员工花名册.xlsx"
'关闭新建的工作簿
ActiveWorkbook.Close
End Sub
Excel VBA对象
最新推荐文章于 2024-09-19 09:26:45 发布