vba 新建并保存工作簿

1、立即窗口显示路径

msgbox thisworkbook.fullname

 

 

 2、新建工作簿并保存

Sub test()
    Rem============== 新建保存工作簿
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim path, name As String
    
    Set wb = Workbooks.Add  '新建工作簿
    Set ws = wb.Worksheets(1)
    With ws
        .name = "信息表"    '修改工作表的标签名称
        Rem========== 设置表头
        .Range("B1:E1") = Array("id", "name", "sex", "birthday")
    End With
    
    path = ThisWorkbook.path
    name = "员工信息表.xlsx"
    wb.SaveAs path & "\" & name  '保存工作簿   
    wb.Close
End Sub

 

 

 

 

 

 

 

 

posted @ 2019-07-09 21:49  赏尔  阅读(2226)  评论(0编辑  收藏  举报