![]() |
VBScript Event Sink Not Firing
Anyone knows why this does not work - i.e. the even sink
excel_SheetChange never fires? Dim myExcel,myWorkbook,mySheet Set myExcel=WScript.CreateObject("Excel.Application"," excel_") Set myWorkbook=myExcel.Workbooks.Add() Set mySheet=myWorkbook.Sheets(1) myExcel.Visible=TRUE myExcel.EnableEvents=TRUE While myExcel.Visible WScript.Sleep(100) Wend Sub excel_SheetChange(ByVal Sh, ByVal Target) WScript.Echo "Sheet Change: Sheet=" & Sh.Name & ", Range=" & Target.Row & "," & Target.Column End Sub Any help welcome. If I get this to work I'll be posting about it on my blog. I've been wanting to sink Excel events to vbscript for ages and just don't seem to be able to manage :( Thanks! AJ -- http://nerds-central.blogpot.com |
VBScript Event Sink Not Firing
1) Make sure the worksheet_change function is on the VBA sheet where you want
it to work. Work_sheet change fucntion only works on one sheet 2) Worksheet_change get only one parameter, not two 3) To get the sheetname use activesheet Sub worksheet_Change(ByVal Target As Range) MsgBox "Sheet Change: Sheet=" & ActiveSheet.Name & _ ", Range=" & Target.Row & "," & Target.Column End Sub "Alex Turner" wrote: Anyone knows why this does not work - i.e. the even sink excel_SheetChange never fires? Dim myExcel,myWorkbook,mySheet Set myExcel=WScript.CreateObject("Excel.Application"," excel_") Set myWorkbook=myExcel.Workbooks.Add() Set mySheet=myWorkbook.Sheets(1) myExcel.Visible=TRUE myExcel.EnableEvents=TRUE While myExcel.Visible WScript.Sleep(100) Wend Sub excel_SheetChange(ByVal Sh, ByVal Target) WScript.Echo "Sheet Change: Sheet=" & Sh.Name & ", Range=" & Target.Row & "," & Target.Column End Sub Any help welcome. If I get this to work I'll be posting about it on my blog. I've been wanting to sink Excel events to vbscript for ages and just don't seem to be able to manage :( Thanks! AJ -- http://nerds-central.blogpot.com |
VBScript Event Sink Not Firing
|
VBScript Event Sink Not Firing
|
All times are GMT +1. The time now is 12:06 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com