473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

addHandler problem

GS
according to help
Dim Obj As New Class1
' Associate an event handler with an event.
AddHandler Obj.Ev_Event, AddressOf EventHandler
is the way to go, so I tried
oBook = oExcel.Workbooks.Add
' Associate an event handler with an event.
AddHandler oBook.WorkbookBeforeClose, AddressOf
xlApp_WorkbookBeforeClose

and I got
Error 4 'WorkbookBeforeClose' is not an event of
'Microsoft.Office.Interop.Excel.Workbook'.

what do I have to do with the handler below to make it work?
Private Sub xlApp_WorkbookBeforeClose(ByVal Wb As Excel.Workbook, _
ByRef Cancel As Boolean)
'Debug.WriteLine("WithEvents: Closing the workbook.")
Wb.Saved = True 'Set the dirty flag to true so there is no prompt to
save
End Sub


Jun 18 '07 #1
2 2044
Hi,
according to help
Dim Obj As New Class1
' Associate an event handler with an event.
AddHandler Obj.Ev_Event, AddressOf EventHandler
is the way to go, so I tried
oBook = oExcel.Workbooks.Add
' Associate an event handler with an event.
AddHandler oBook.WorkbookBeforeClose, AddressOf
xlApp_WorkbookBeforeClose

and I got
Error 4 'WorkbookBeforeClose' is not an event of
'Microsoft.Office.Interop.Excel.Workbook'.
The event is fired from the Application object. So you would need something
like

AddHandler oExcel.WorkbookBeforeClose, AddressOf xlApp_WorkbookBeforeClose

Assuming that oExcel is of type Excel.Application.
--
SvenC

Jun 18 '07 #2
GS
wonderful.
Thank you vary much for your helpful and detailed answer.

"SvenC" <Sv***@community.nospamwrote in message
news:D9**********************************@microsof t.com...
Hi,
according to help
Dim Obj As New Class1
' Associate an event handler with an event.
AddHandler Obj.Ev_Event, AddressOf EventHandler
is the way to go, so I tried
oBook = oExcel.Workbooks.Add
' Associate an event handler with an event.
AddHandler oBook.WorkbookBeforeClose, AddressOf
xlApp_WorkbookBeforeClose

and I got
Error 4 'WorkbookBeforeClose' is not an event of
'Microsoft.Office.Interop.Excel.Workbook'.

The event is fired from the Application object. So you would need
something
like

AddHandler oExcel.WorkbookBeforeClose, AddressOf xlApp_WorkbookBeforeClose

Assuming that oExcel is of type Excel.Application.
--
SvenC

Jun 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Supra | last post by:
how do i do get menuitem "Connect" in addhandler ? Private Sub mnuIrc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuIrcConnect.Click, mnuIrcPref.Click,...
0
by: Jeffrey A. Voigt | last post by:
Can someone take a quick glace at my code and tell me why my AutoPostBackHandler function does not get fired off at all? What I'm trying to do is get all of the Buttons and DropDownList controls...
3
by: Nathan Sokalski | last post by:
I am using the AddHandler statement to add a CheckedChanged event handler to a series of RadioButtons that I create in a loop. However, the handler is not being called for a reason I cannot...
1
by: Luis Esteban Valencia Muñoz | last post by:
Have a dropdownlist created in my LoadMain() which is called from the Page_load: ************************PAGE LOAD********************8Private Sub Page_Load(ByVal sender As System.Object, ByVal e...
4
by: DJ | last post by:
Good morning, Still new at this so please bear with me. I am creating a table dynamically using webcontrols based on the output of a sproc from my database.The table represents test instances...
2
by: Just Me | last post by:
When a document is to be printed I call a method that contains an AddHandler statement. I just realized that if a second copy is to be printed the method is called and the AddHandler is executed...
6
by: Carlo3030 | last post by:
Been reading Dino Esposito's Article "A DetailsView Control for ASP.NET 1.x" found in the msdn Library. His example was created using VB.NET. I am trying to convert the example (DetailsView...
5
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class...
5
by: ugavnholt | last post by:
Hi All, I'm having a problem with a small bit of code: Dim deleteButton = New System.Web.UI.WebControls.ImageButton deleteButton.imageURL = "images/icondelete.gif" deleteButton.ToolTip =...
15
by: Nathan Sokalski | last post by:
I have a section of my code that dynamically creates LinkButtons to allow the user to go to the page containing a question they have not answered. The code that creates the LinkButton is called, as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.