Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 13
Default Difference between Excel.WorkbookEvents_SheetChangeEventHandler and Excel.AppEvents_SheetChangeEventHandler

Hi i want to what is the difference between
Excel.WorkbookEvents_SheetChangeEventHandler and
Excel.AppEvents_SheetChangeEventHandler. i want to fire an event When
any cell changes its value because of an external link. But the event
is getting fired only for the source workbook and not for the dependent
workbook.

Suppose i have 2 workbooks. Hello.xls and Fine.xls. Assume cell B1 in
HelloSheet1 of Hello.xls gets its input from cell A2 of FineSheet3 in
Fine.xls. When i change the value in Fine.xls , the value gets updated
in Hello.xls. But the event gets fired only for Fine.xls and not for
Hello.xls. I want to fire an event when value cell B1 in HelloSheet1 of
Hello.xls is changed because of cell A2 of FineSheet3 in Fine.xls.

This is what i am doing

namespace ShtChangeEvnt
{
public class Form2 : System.Windows.Forms.Form
{
public Excel.ApplicationClass xlAppNew=null;
private Excel.AppEvents_WorkbookOpenEventHandler EventDel_WorkbookOpen;
private Excel.WorkbookEvents_SheetChangeEventHandler
EventDel_WBSheetChange;
private Excel.AppEvents_SheetChangeEventHandler
EventDel_AppSheetChange;
private Excel.Workbook xlBook;
private Excel.Worksheet xlSheet ;

public void AddHandler(string strFPath, int OpenFlag)
{
if(xlAppNew==null) xlAppNew=new Excel.ApplicationClass();
if(OpenFlag==1)
{
EventDel_WorkbookOpen=
new Excel.AppEvents_WorkbookOpenEventHandler( WBopen);
xlAppNew.WorkbookOpen += EventDel_WorkbookOpen;

EventDel_AppSheetChange= new Excel.AppEvents_SheetChangeEventHandler (
AppSheetChange);
xlAppNew.SheetChange += EventDel_AppSheetChange;

xlAppNew.Visible=true;
xlAppNew.UserControl=true;
xlBook= xlAppNew.Workbooks.Open(strFPath,3,Missing.Value ,...);
}// end if
else
{
Excel.Workbook xlBook2=xlAppNew.Workbooks.Open(strFPath,3,Missing .Value
....);

EventDel_WBSheetChange= new
Excel.WorkbookEvents_SheetChangeEventHandler( WBSheetChange);
xlBook2.SheetChange += EventDel_WBSheetChange; }// end else
}// end AddHandler

private void WBopen(Excel.Workbook Wb)
{
EventDel_WBSheetChange= new
Excel.WorkbookEvents_SheetChangeEventHandler( WBSheetChange);
xlAppNew.ActiveWorkbook.SheetChange += EventDel_WBSheetChange;
}// end WBopen

private void AppSheetChange(object Sh, Excel.Range Target)
{
logToFile("C:\\AppSheetChangeEvnt.txt","Hi tis is AppEvnt fired fr
"+Target.Worksheet.Name.ToString());
}// end AppSheetChange

private void WBSheetChange(object Sh, Excel.Range Target)
{
logToFile("C:\\WBSheetChangeEvnt.txt","Hi tis is WBEvnt fired fr
"+Target.Worksheet.Name.ToString());
}// end WBSheetChange

public static void logToFile(string strPath, string strData)
{
code to create/open txt file
} } }

When i change the value in Fine.xls , the value gets updated in
Hello.xls. But both the events get fired only for Fine.xls and not for
Hello.xls . the txt files contain
Hi tis is AppEvnt fired fr FineSheet3 in AppSheetChangeEvnt.txt
and
Hi tis is WBEvnt fired fr FineSheet3 in WBSheetChangeEvnt.txt

I want to capture the SheetChange occuring in Hello.xls because of
Fine.xls. Please someone guide me in this regard and let me if i am
going wrong anywhere.

With Regards
Daffo

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Averaging Time Difference vldavis809 Excel Discussion (Misc queries) 1 July 8th 06 09:42 AM
Formula to find the working days difference between to dates? Mudgeman Excel Discussion (Misc queries) 2 May 15th 06 04:26 AM
Time difference Stephanie Excel Worksheet Functions 5 March 21st 06 10:06 PM
Difference between two months leitek.com Excel Worksheet Functions 5 March 13th 06 09:10 PM
charting a difference of 2 columns' w/o adding a difference column Wab Charts and Charting in Excel 4 July 27th 05 02:37 AM


All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"