MS Project - IConnectionPointContainer::EnumConnectionPoints fails

T

Todor Todorov

I am trying to establish an event sink to a MS Project OLE
server. The client is written in Smalltalk, so it uses
automation extensively to determine what the OLE server is
capable of.

Here is the Smalltalk kode translated to VB pseudocode.
' Create a MS Project automation server.
Set app=CreateObject("MSProject.Application")
' If the next line succeeds, the events are supported
Set icpc=app.QueryInterface(IID_IConnectionPointContainer)
' Get an enumerator to determine event interfaces
Set ienumcp = icpc.EnumConnectionPoints()

The MSDN documentation says to query interface for
IConnectionPointContainer to determine if events are
supported. It succeeds, so they are. Next, enumerate the
supported event interfaces with EnumConnectionPoints. But
MS Projects fails here with DISP_E_UNKNOWNINTERFACE. Why?
It's not a documented return value. The documentation even
says: "Returning E_NOTIMPL is specifically disallowed
because, with the exception of type information, there
would be no other means through which a caller could find
the IIDs of the outgoing interfaces."

What's wrong with MS Project? How do I solve this issue?
 
W

Wei-Dong Xu [MSFT]

Hi Todor,

Thank you for using Microsoft newsgroup!

Currently I am finding somebody who could help you on it. We will post back
in newsgroup as soon as possible.

Thank you for your understanding!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Gary Chang

Hi Todor,

Thanks for using Microsoft MSDN Managed Newsgroup.
My name is Gary, and I will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.

From your description, I understand that you try to establish an event sink
using SmallTalk to a MS Project OLE
server, but the SmallTalk code fails at "icpc.EnumConnectionPoints()"(VB
pseudocode) with DISP_E_UNKNOWNINTERFACE.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.
But MS Projects fails here with DISP_E_UNKNOWNINTERFACE. Why?
It's not a documented return value. The documentation even
says: "Returning E_NOTIMPL is specifically disallowed

The E_NOTIMPL implies that the EnumConnectionPoints() is a member function
of a vtbl interface, however the DISP_E_UNKNOWNINTERFACE error reveals you
get a dispatch interface and it don't have such a method, so I think maybe
you have just queried a wrong icpc interface.

The following KB link has a similar topic with your problem, maybe you can
find something useful from it:
HOWTO: Catch Microsoft Word97 Application Events Using VC++
http://support.microsoft.com/?id=183599



Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
T

Todor Todorov

Hello Gary!

Gary Chang said:
Hi Todor,

Thanks for using Microsoft MSDN Managed Newsgroup.
My name is Gary, and I will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.

From your description, I understand that you try to establish an event sink
using SmallTalk to a MS Project OLE
server, but the SmallTalk code fails at "icpc.EnumConnectionPoints()"(VB
pseudocode) with DISP_E_UNKNOWNINTERFACE.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Correct! It returns an error. More precisely ...
Project 2000 returns: HRESULT: 0x8000FFFF
Project 2003 returns: HRESULT: 0x80020001

Smalltalk maps those return values to E_UNEXPECTED and
DISP_E_UNKNOWNINTERFACE.
The E_NOTIMPL implies that the EnumConnectionPoints() is a member function
of a vtbl interface, however the DISP_E_UNKNOWNINTERFACE error reveals you
get a dispatch interface and it don't have such a method, so I think maybe
you have just queried a wrong icpc interface.

The following KB link has a similar topic with your problem, maybe you can
find something useful from it:
HOWTO: Catch Microsoft Word97 Application Events Using VC++
http://support.microsoft.com/?id=183599

This is an ugly work around. I'll have to modify or rewrite some central
Smalltalk code to manually accept the IID of the event interface. I'll also
have to hardcode constants in my application, which goes against the idea of
automation. It won't be much automation if we are back to C++ where the
developer must do everything himself or herself.

Can you confirm that the error I get is due to deffect in MS Project (and
probably Word), so I will stop focusing on EnumConnectionPoints and make
changes necesary to hardcode the IID constant in my app?

Thanks!

-- Todor Todorov
 
G

Greg Ellison [MS]

Hello Todor,

I am doing some research to determine if this is a defect in MS Project
with regards to EnumConnectionPoints. I will send another post with my
findings. Thank you for your patience.

For information and sample code for integrating Office with Visual Basic,
Visual C++, Internet Scripts, and other programming languages, please see
http://msdn.microsoft.com/library/techart/VSOfficeDev.htm. This site
contains the most up-to-date information for using developer tools for
Office integration and extensibility.

Best regards,
Greg Ellison
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? Please visit the Microsoft Security Home Page
(http://www.microsoft.com/security) for the latest news on security updates.

--------------------
 
G

Greg Ellison [MS]

Hello Todor,

I have reproduced the problem you described, where EnumConnectionPoints
returns DISP_E_UNKNOWNINTERFACE when automating Microsoft Project 2003 from
Visual C++. I did not experience the problem with Excel or Word. I got
back S_OK. Therefore this appears to be a problem in Project 2003. I am
trying to see if more information is available, so look for another post
hopefully on Monday.

For information and sample code for integrating Office with Visual Basic,
Visual C++, Internet Scripts, and other programming languages, please see
http://msdn.microsoft.com/library/techart/VSOfficeDev.htm. This site
contains the most up-to-date information for using developer tools for
Office integration and extensibility.

Best regards,
Greg Ellison
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? Please visit the Microsoft Security Home Page
(http://www.microsoft.com/security) for the latest news on security updates.
 
T

Todor Todorov

Hello Greg,

I see you've got the error as well. I can't remember about Excel, but Word returns S_OK. Could you please try to enumerate the IEnumConnectionPoints interface returned by Word to determine the connection points count? It's where I get in trouble with Word.

Here is a small VBScript code to demonstrate working automation event binding.
========= Save this to a VBS file ===============
Option Explicit

Dim appl, signaled
Set appl = CreateObject("Visio.Application")
appl.Visible = True
WScript.ConnectObject appl, "VisioAppl_"
Do While Not signaled
WScript.Sleep 100
Loop
MsgBox "VBScript execution ended."

Sub VisioAppl_BeforeQuit(app)
MsgBox "You are about to quit Visio."
signaled = True
End Sub
=====================================

Here's the same code but using Project - if fails on line 6!
========= Save this to a VBS file ===============
Option Explicit

Dim appl, signaled
Set appl = CreateObject("MSProject.Application")
appl.Visible = True
WScript.ConnectObject appl, "ProjectAppl_"
Do While Not signaled
WScript.Sleep 100
Loop
MsgBox "VBScript execution ended."

Sub ProjectAppl_ProjectBeforeClose(pj, Cancel)
Cancel = (MsgBox("You are about to quit Project. Quit?", vbYesNo) = vbNo)
signaled = Cancel
End Sub
=====================================

Thanks!

-- Todor


----- Greg Ellison [MS] wrote: -----

Hello Todor,

I have reproduced the problem you described, where EnumConnectionPoints
returns DISP_E_UNKNOWNINTERFACE when automating Microsoft Project 2003 from
Visual C++. I did not experience the problem with Excel or Word. I got
back S_OK. Therefore this appears to be a problem in Project 2003. I am
trying to see if more information is available, so look for another post
hopefully on Monday.

For information and sample code for integrating Office with Visual Basic,
Visual C++, Internet Scripts, and other programming languages, please see
http://msdn.microsoft.com/library/techart/VSOfficeDev.htm. This site
contains the most up-to-date information for using developer tools for
Office integration and extensibility.

Best regards,
Greg Ellison
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? Please visit the Microsoft Security Home Page
(http://www.microsoft.com/security) for the latest news on security updates.
 
G

Greg Ellison [MS]

Hello Todor,

Thank you for your patience. After consulting with my colleagues on this
issue, we consider this a bug in MS Project since it does not occur in
Excel or Word. I have submitted a bug report to the Office group so that
they can review this problem and make a determination if this can be
addressed in a future release of MS Project. In order to use MS Project
events from your application, the advice we have is to use
FindConnectionPoint as mentioned in the following links:

238983 - HOWTO: Trap Events Exposed by Office Applications
http://support.microsoft.com/default.aspx?scid=KB;en-us;238983

183599 - HOWTO: Catch Microsoft Word97 Application Events Using VC++
http://support.microsoft.com/default.aspx?scid=KB;en-us;183599

For information and sample code for integrating Office with Visual Basic,
Visual C++, Internet Scripts, and other programming languages, please see
http://msdn.microsoft.com/library/techart/VSOfficeDev.htm. This site
contains the most up-to-date information for using developer tools for
Office integration and extensibility.

Best regards,
Greg Ellison
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? Please visit the Microsoft Security & Privacy Center
(http://www.microsoft.com/security) for the latest news on security updates.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top