Novice: Where is Excel's NewWorkbook Event?

P

Peter

Hello,

I am trying to hook to the NewWorkbook Event in Excel but I am unable to
hook to the event. The following code:

Excel.Application appExcel = new Excel.Application();
Excel.AppEvents_NewWorkbookEventHandler excelevent;
excelevent = new Excel.AppEvents_NewWorkbookEventHandler(ExcelNewWorkbook);
appExcel.NewWorkbook += excelevent; // COMPILER ERROR

generates the following error:
Cannot implicitly convert type
'Microsoft.Office.Interop.Excel.AppEvents_NewWorkbookEventHandler' to
'Microsoft.Office.Core.NewFile'

Property or indexer
'Microsoft.Office.Interop.Excel._Application.NewWorkbook' cannot be assigned
to -- it is read only

It appears that Excel.Application.NewWorkbook is not event despite MS
documentation:

Private Sub object_NewWorkbook(ByVal Wb As Workbook)
object An object of type Application declared with events in a class
module. For more information, see Using Events with the Application Object .
Wb The new workbook.


Any Ideas?

Many Thanks
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top