473,408 Members | 2,734 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,408 software developers and data experts.

Binding for Office automation

Max
I am using late binding to automate my code to Microsoft Outlook and I'm getting an error in my code:

Expand|Select|Wrap|Line Numbers
  1. Type objClassType = Type.GetTypeFromProgID("Outlook.Application");
  2. objApp_Late = Activator.CreateInstance(objClassType);
  3.  
  4. objInspectors_Late = objApp_Late.GetType().InvokeMember("Inspectors", BindingFlags.InvokeMethod, null, objApp_Late, null);
  5. e_InspectorNewEvent_Late = objInspectors_Late.GetType().GetEvent("NewInspector");
  6.  
At this point e_InspectorNewEvent_Late is null. Can someone tell me why the last line of code does not return an EventInfo?

Nov 17 '05 #1
2 1818
Max,

Inspectors is not a method. Rather, it is a property that returns a
collection. That being the case, you should get the property info for the
property, and then call GetValue.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Max" <ma******@yahoo.com> wrote in message
news:eX**************@TK2MSFTNGP15.phx.gbl...
I am using late binding to automate my code to Microsoft Outlook and I'm
getting an error in my code:

Expand|Select|Wrap|Line Numbers
  1.  Type objClassType = Type.GetTypeFromProgID("Outlook.Application");
  2.  objApp_Late = Activator.CreateInstance(objClassType);
  3.  objInspectors_Late = objApp_Late.GetType().InvokeMember("Inspectors",
  4.  BindingFlags.InvokeMethod, null, objApp_Late, null);
  5.  e_InspectorNewEvent_Late =
  6.  objInspectors_Late.GetType().GetEvent("NewInspector");
  7.  

At this point e_InspectorNewEvent_Late is null. Can someone tell me why
the last line of code does not return an EventInfo?

Nov 17 '05 #2

"Max" <ma******@yahoo.com> wrote in message
news:eX**************@TK2MSFTNGP15.phx.gbl...
I am using late binding to automate my code to Microsoft Outlook and I'm
getting an error in my code:

Expand|Select|Wrap|Line Numbers
  1.  Type objClassType = Type.GetTypeFromProgID("Outlook.Application");
  2.  objApp_Late = Activator.CreateInstance(objClassType);
  3.  objInspectors_Late = objApp_Late.GetType().InvokeMember("Inspectors",
  4.  BindingFlags.InvokeMethod, null, objApp_Late, null);
  5.  e_InspectorNewEvent_Late =
  6.  objInspectors_Late.GetType().GetEvent("NewInspector");
  7.  

At this point e_InspectorNewEvent_Late is null. Can someone tell me why
the last line of code does not return an EventInfo?


This is simply not possible using late binding.
COM objects that enter the CLR that don't support IProvideClassInfo or do
not have any interop assembly registered will be wrapped in a generic type
'System.__ComObject'. That means that
objInspectors_Late.GetType().GetEvent("NewInspecto r");
will return null as objInspectors_Late, which is of type __ComObject, does
not "expose" the 'NewInspector' event.

Willy.
Nov 17 '05 #3

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

Similar topics

7
by: PC Datasheet | last post by:
I have this: Dim Cbr As Object Dim Ctl As Object Set Cbr = Application.Commandbars("CourseCalendarMonth") Set Ctl = Application.Commandbars("CourseCalendarMonth").Controls("CalendarMonth") Is...
3
by: deko | last post by:
So I've decided to convert from Early Binding to Late Binding. Now that I've been baptized, I need some instruction in the faith. My former ways were thus: Dim xlapp As Excel.Application Set...
9
by: Zlatko Matić | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws...
4
by: Richard | last post by:
Office Addins are easy in .NET. Try this from Visual Studio's main menu: File New Project "Other Projects" Extensibility Projects Shared Addin Run the wizard and you're off...
2
by: Mystery Man | last post by:
We are developing a C# application that has many interfaces to the Microsoft suite (eg Word, Excel, Outlook, Powerpoint, etc). We need to support Office 97, 2000, 2002 and any future versions. ...
0
by: Dick Peterson | last post by:
I am trying to automate a PowerPoint process from C#, using late binding because the app needs to be independent of Office versions. I found an article on this in MSKB article 302902 (...
2
by: Alex Maghen | last post by:
Hi. I've seen several KBs on using .NET for MS Office Automation. But I have a particular question: I am developing a somewhat stand-alone .ASPX page which will need to do some relatively simple MS...
8
by: scorpion53061 | last post by:
I am sorry for this but I am not getting an answer elsewhere so I thought I would try here. It seems the safer way to go prior to deployment is to change my early binding to late binding to...
0
by: Marco Singer | last post by:
Hi all, I want to create an Office automation client for Office 97 (and newer) which should automate Access, Excel and Word. On my developer computer I have Office XP installed. In KB244167...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.