Then again, I am VB centric, so was trying to find a "universal" solution. But since Lua "is" the default now, in section 3.3.3 of the LuaCOM reference:
-- Creates the COM object
--
calendar = luacom.CreateObject("MSCAL.Calendar")
if calendar == nil then
os.exit(1)
end
-- Creates implementation table
--
calendar_events = {}
function calendar_events:AfterUpdate()
print("Calendar updated!")
end
-- Connects object and table
--
res, cookie = luacom.Connect(calendar, calendar_events)
if res == nil then
exit(1)
end
-- This should trigger the AfterUpdate event
--
calendar:NextMonth()
-- Creates the COM object
--
calendar = luacom.CreateObject("MSCAL.Calendar")
if calendar == nil then
os.exit(1)
end
-- Creates implementation table
--
calendar_events = {}
function calendar_events:AfterUpdate()
print("Calendar updated!")
end
-- Connects object and table
--
res, cookie = luacom.Connect(calendar, calendar_events)
if res == nil then
exit(1)
end
-- This should trigger the AfterUpdate event
--
calendar:NextMonth()