View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Olaerts Ludo Olaerts Ludo is offline
external usenet poster
 
Posts: 1
Default making new wkb and place an event in it

I' am starting from an open excel work- book a code. This cod
contents:
Step 1: I would add a new workbook
Step 2: I would insert a commandbutton on sheet(1) that listen to
code (e.g. a msgBox)
Step 3: I want to include a event workbook_beforeSaved (e.g. a msgBox)
Is it possible to write one code in the open workbook that do thos
things
I have made step 1 succesfully:
Function CreateNewWorkbook(Optional intNumberSheets As Integer = 1
As Workbook
Dim wkbNew As Excel.Workbook

On Error GoTo CreateNewWorkbook_Err

Set wkbNew = Workbooks.Add
Set CreateNewWorkbook = wkbNew
Application.SheetsInNewWorkbook = intNumberSheets

CreateNewWorkbook_End:
Exit Function

CreateNewWorkbook_Err:
Set CreateNewWorkbook = Nothing
wkbNew.Close savechanges:=False
Set wkbNew = Nothing
Resume CreateNewWorkbook_End
End Functio

--
Message posted from http://www.ExcelForum.com