Click to See Complete Forum and Search --> : CreateObject
danasegarane
May 8th, 2007, 01:01 AM
Dear All,
In vb.net we can give like this for getting illustrator application
appRef = CreateObject("Illustrator.Application")
in C#.net what we can give for getting illustrator application
Thanks in Advance
jmcilhinney
May 8th, 2007, 01:24 AM
I would guess Activator.CreateInstance, although I'm not 100% sure how that behaves with COM components.
Bombdrop
May 8th, 2007, 05:57 AM
Have a look at the following this shows how i hook up to Outlook in my apps.
//Make sure outlook is on the machine;
Type outLookType = Type.GetTypeFromProgID("Outlook.Application" , false);
if (outLookType != null) {
//see if outlook open and assign that instance to outApp.
try {
this.outApp = Marshal.GetActiveObject("Outlook.Application") as ol._Application;
} catch {
}
if (this.outApp != null) {
this.CanQuitOutLook = false;
} else {
this.outApp = Activator.CreateInstance(outLookType) as ol._Application;
}//(this.outApp!=null)
Hope this helps!!
:wave: :thumb: :wave:
danasegarane
May 8th, 2007, 10:56 PM
Dear BP,
Thanks for your reply.I got this error when i compiled this code.
I have set reference to Microsoft outlook Library.
Error 1 'WindowsApplication13.Form1' does not contain a definition for 'outApp'
jmcilhinney
May 8th, 2007, 11:08 PM
When people post code you should assume that it is an example only and probably cannot be just copied and pasted into your app without some adjustment.
The fact that it's referred to as:this.outAppmeans that it is obviously a member variable. Have you declared a member variable with that name?
siva_boss2003
May 8th, 2007, 11:25 PM
Dear JMC,
I cannot get you. this.outApp is a member variable its ok. but what type it must be declared.
jmcilhinney
May 8th, 2007, 11:58 PM
Dear JMC,
I cannot get you. this.outApp is a member variable its ok. but what type it must be declared.What is the point of this whole exercise? To create an instance of the Outlook application. That's what outApp is and should be declared as, exactly as Bombdrop's example code shows:Type outLookType = Type.GetTypeFromProgID("Outlook.Application" , false);this.outApp = Marshal.GetActiveObject("Outlook.Application") as ol._Application;this.outApp = Activator.CreateInstance(outLookType) as ol._Application;
jmcilhinney
May 9th, 2007, 01:10 AM
Note also that Bombdrop would have imported and aliased the namespace that the _Application class (or interface, which ever it is in that silly COM world ;)) is a member of. That would look like this, if I remember correctly:using ol = Microsoft.Office.Interop.Outlook;
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.