By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,551 Members | 2,741 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,551 IT Pros & Developers. It's quick & easy.

Outlook application object

P: n/a
I want to create an Outlook-appointment using .NET VC.
My Visual Basic example starts with:

Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
Microsoft.Office.Interop.Outlook.Application

But my C++ translation:

Microsoft::Office::Interop::Outlook::Application *oApp = new
Microsoft::Office::Interop::Outlook::Application;
does not compile. ('You cannot create an instance of an interface' or
something like that). Does anybody know, what's wrong here?

Markus
Sep 26 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Markus,

"Markus Donath" <ne******@microsoft.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
>I want to create an Outlook-appointment using .NET VC.
My Visual Basic example starts with:

Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
Microsoft.Office.Interop.Outlook.Application

But my C++ translation:

Microsoft::Office::Interop::Outlook::Application *oApp = new
Microsoft::Office::Interop::Outlook::Application;
does not compile. ('You cannot create an instance of an interface' or
something like that). Does anybody know, what's wrong here?
Why not copy the exact error message?

Do you use VC2003 or VC2005?

In VC2003 I would expect that something like ApplicationClass or
_ApplicationClass would be available which represents the so called COM
coclass. A coclass is an object you can instantiate and use by an interface
it implements, which would be Application in thiscase.

In VC2005 you would want to use the new C++/CLI which uses ^ instead of *
for managed pointers and gcnew instead of new.

--
SvenC
Markus

Sep 26 '06 #2

P: n/a
"Markus Donath" <ne******@microsoft.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
>I want to create an Outlook-appointment using .NET VC.
My Visual Basic example starts with:

Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
Microsoft.Office.Interop.Outlook.Application

But my C++ translation:

Microsoft::Office::Interop::Outlook::Application *oApp = new
Microsoft::Office::Interop::Outlook::Application;
does not compile. ('You cannot create an instance of an interface' or
something like that). Does anybody know, what's wrong here?
You have to use CoCreateInstance to create an instance of a COM class. You
can't do it with new.

-cd
Sep 26 '06 #3

P: n/a
SvenC wrote:
Hi Markus,

"Markus Donath" <ne******@microsoft.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
>I want to create an Outlook-appointment using .NET VC.
My Visual Basic example starts with:

Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
Microsoft.Office.Interop.Outlook.Application

But my C++ translation:

Microsoft::Office::Interop::Outlook::Applicatio n *oApp = new
Microsoft::Office::Interop::Outlook::Applicatio n;
does not compile. ('You cannot create an instance of an interface' or
something like that). Does anybody know, what's wrong here?

Why not copy the exact error message?
Because it is produced by German version of Visual Studio .NET 2003 and
thus, the error message is in German:

error C3153: 'Microsoft::Office::Interop::Outlook::Application' : Sie
können keine Instanz einer Schnittstelle erstellen
>
Do you use VC2003 or VC2005?
VC2003
>
In VC2003 I would expect that something like ApplicationClass or
_ApplicationClass would be available which represents the so called COM
coclass. A coclass is an object you can instantiate and use by an interface
it implements, which would be Application in thiscase.
Have you got an example?
>
In VC2005 you would want to use the new C++/CLI which uses ^ instead of *
for managed pointers and gcnew instead of new.

--
SvenC
>Markus

Sep 27 '06 #4

P: n/a
Carl Daniel [VC++ MVP] wrote:
"Markus Donath" <ne******@microsoft.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
>I want to create an Outlook-appointment using .NET VC.
My Visual Basic example starts with:

Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
Microsoft.Office.Interop.Outlook.Application

But my C++ translation:

Microsoft::Office::Interop::Outlook::Applicatio n *oApp = new
Microsoft::Office::Interop::Outlook::Applicatio n;
does not compile. ('You cannot create an instance of an interface' or
something like that). Does anybody know, what's wrong here?

You have to use CoCreateInstance to create an instance of a COM class. You
can't do it with new.

-cd

I would be happy, if you could give an example for 'CoCreateInstance' in
this context.

Markus
Sep 27 '06 #5

P: n/a

"Markus Donath" <ne******@microsoft.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
|I want to create an Outlook-appointment using .NET VC.
| My Visual Basic example starts with:
|
| Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
| Microsoft.Office.Interop.Outlook.Application
|
| But my C++ translation:
|
| Microsoft::Office::Interop::Outlook::Application *oApp = new
| Microsoft::Office::Interop::Outlook::Application;
|
|
| does not compile. ('You cannot create an instance of an interface' or
| something like that). Does anybody know, what's wrong here?
|
| Markus

Application refers to an interface which obviously cannot be instantiated,
you need to create an instance of ApplicationClass like :

Microsoft::Office::Interop::Outlook::ApplicationCl ass *oApp = new
Microsoft::Office::Interop::Outlook::ApplicationCl ass();
Willy.
Sep 27 '06 #6

P: n/a

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:%2***************@TK2MSFTNGP02.phx.gbl...
| "Markus Donath" <ne******@microsoft.comwrote in message
| news:OO**************@TK2MSFTNGP04.phx.gbl...
| >I want to create an Outlook-appointment using .NET VC.
| My Visual Basic example starts with:
| >
| Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
| Microsoft.Office.Interop.Outlook.Application
| >
| But my C++ translation:
| >
| Microsoft::Office::Interop::Outlook::Application *oApp = new
| Microsoft::Office::Interop::Outlook::Application;
| >
| >
| does not compile. ('You cannot create an instance of an interface' or
| something like that). Does anybody know, what's wrong here?
|
| You have to use CoCreateInstance to create an instance of a COM class.
You
| can't do it with new.
|
| -cd
|

Hmmm... this is a managed client, and the interop assembly is a managed
wrapper, so there is no problem to new an instance of the ApplicationClass.

Willy.

|
Sep 27 '06 #7

P: n/a
Willy Denoyette [MVP] wrote:
"Markus Donath" <ne******@microsoft.comwrote in message
news:OO**************@TK2MSFTNGP04.phx.gbl...
|I want to create an Outlook-appointment using .NET VC.
| My Visual Basic example starts with:
|
| Dim oApp As Microsoft.Office.Interop.Outlook.Application = New
| Microsoft.Office.Interop.Outlook.Application
|
| But my C++ translation:
|
| Microsoft::Office::Interop::Outlook::Application *oApp = new
| Microsoft::Office::Interop::Outlook::Application;
|
|
| does not compile. ('You cannot create an instance of an interface' or
| something like that). Does anybody know, what's wrong here?
|
| Markus

Application refers to an interface which obviously cannot be instantiated,
you need to create an instance of ApplicationClass like :

Microsoft::Office::Interop::Outlook::ApplicationCl ass *oApp = new
Microsoft::Office::Interop::Outlook::ApplicationCl ass();
Willy.

Okay, that's it. Thank you.
Markus
Sep 27 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.