How do I attach event handlers to a late-bound object (C#)?
-
I've created a control to embed a MSWord document based on several projects here. The embeding it's self works great but I am having trouble figuring out how to bind event handlers. See below for an example. Word.DocumentBeforeClose += new ApplicationEvents4_DocumentBeforeCloseEventHandler(OnClose); The above line works with doing early binding, but due to the variations in version of Office being used in the company, I need to do late binding. Anyone got any ideas? Thank you, Eric Ritzie
-
I've created a control to embed a MSWord document based on several projects here. The embeding it's self works great but I am having trouble figuring out how to bind event handlers. See below for an example. Word.DocumentBeforeClose += new ApplicationEvents4_DocumentBeforeCloseEventHandler(OnClose); The above line works with doing early binding, but due to the variations in version of Office being used in the company, I need to do late binding. Anyone got any ideas? Thank you, Eric Ritzie
I Don't think you can do it that way. There are 2 options that I thought: 1. Option: Install same version of Office 2. Option: Use different module (dll) based on Office installed 3. Option: (I Don't know how to do it in C# Use compiler directive and compile different exe files
-
I Don't think you can do it that way. There are 2 options that I thought: 1. Option: Install same version of Office 2. Option: Use different module (dll) based on Office installed 3. Option: (I Don't know how to do it in C# Use compiler directive and compile different exe files
Hmmm.....Option 1 is not really feesable because of cost. Options 2 and 3 would be a big pain although they are doable. I think there has to be a way to do what I am trying to accompish biw the Interop. I'm able to get and set properties by using type.InvokeMember() and I can even get an event object by using type.GetEvent(), I just need that last little bit to bind it to my event handlers. Thank you, Eric Ritzie