View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Sugestion for the Excel Guys

Hi Albert,

Why not simply change SheetsInNewWorkbook if you need to and reset as
original.

Sub test()
Dim wbNew As Workbook

AddNewBook wbNew, 6

MsgBox wbNew.Worksheets.Count & " worksheets", , wbNew.Name

End Sub

Sub AddNewBook(wb As Workbook, Optional nSheets As Long = 0)
Dim nSheetsDefault As Long

On Error GoTo errExit
If nSheets 0 Then
nSheetsDefault = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = nSheets
End If

Set wb = Application.Workbooks.Add

errExit:
If nSheetsDefault 0 Then
Application.SheetsInNewWorkbook = nSheetsDefault
End If
End Sub

Regards,
Peter T
"Albert" wrote in message
...
Hi.
It would be very nice if SheetsInNewWorkbook was one of the arguments for
the Workbooks.Add procedure.
Maybe I can do this somehow through my PersonalMacros Addin?
Best regards,
Albert C