- Sub 新建工作簿 ()
- Dim wb As Workbook
- Set wb = Workbooks.Add
- With wb
- .SaveAs "d:\test\Mybook"
- .Save
- .Close
- End With
- End Sub
- Sub 打开工作簿()
- Dim wb As Workbook
- Dim OtherWb As String
- OtherWb = InputBox("输入工作簿名称:", "工作簿 _名称", "mybook.xlsx")
- For Each wb In Workbooks
- If LCase(wb.Name) = LCase(OtherWb) Then
- MsgBox "工作簿" & OtherWb & "已经被打开!", vbInformation
- Exit Sub
- End If
- Next
- MsgBox "工作簿" & OtherWb & "没有被打开!", vbInformation
- End Sub