How to call app (eg, Outlook) from Add-in Express for IE addon?

Add-in Express™ Support Service
That's what is more important than anything else

How to call app (eg, Outlook) from Add-in Express for IE addon?
 
Vadim Usmanov




Posts: 18
Joined: 2012-03-23
Hello,
Please tell me: is there a way to call app (eg, Outlook) from Add-in Express for IE addon?

Following the example of code that does not work (security?):

  Dim myOlApp, myMail
        myOlApp = CreateObject("Outlook.Application")
        myMail = myOlApp.CreateItem(Outlook.OlItemType.olMailItem) 'create new mail
        myMail.Display() 'Display Mail
Posted 31 Mar, 2012 15:00:55 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Vadim,

Yes, there is a way. Please use the COM Automation technology. You can read more about this in the Automating Applications Using the Office Object Model article in MSDN. Also I have found a sample code for you.
.NET, Extended MAPI, Windows Phone & RT
Posted 02 Apr, 2012 04:37:28 Top
Vadim Usmanov




Posts: 18
Joined: 2012-03-23
Thanks, Eugene!
I can create a new mail in Outlook (NB: run IE-addon outside VS!):
Dim myOlApp, myMail   
      myOlApp = CreateObject("Outlook.Application")   
      myMail = myOlApp.CreateItem(Outlook.OlItemType.olMailItem) 'create new mail
      Dim DocURL = Me.HTMLDocument.url 
      myMail.Subject = DocURL
      myMail.Display() 'Display Mail  


I also can create Excel object using code:
   Dim objExcel = CreateObject("Excel.Application")
        Dim ExcelWorkbook = objExcel.Workbooks.Add
        Dim ExcelWorksheet = ExcelWorkbook.Worksheets(1)
        objExcel.Visible = True

        Dim Wbook
        For Each Wbook In objExcel.Workbooks 
            MsgBox("Wbook.Name: " & Wbook.Name)
        Next Wbook

But I couldn't get running Excel:
Dim objExcel = GetObject(, "Excel.Application") 

What do you think about this issue?
Posted 02 Apr, 2012 18:26:29 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Vadim,

Do you get any exceptions or errors messages?

Anyway, please take a look at the GetObject or GetActiveObject cannot find a running Office application article and the similar forum thread.
.NET, Extended MAPI, Windows Phone & RT
Posted 03 Apr, 2012 04:34:23 Top
Vadim Usmanov




Posts: 18
Joined: 2012-03-23
Thank you, Eugene!
I tried to use the article GetObject or GetActiveObject cannot find a running Office application. It did not help me. Exception is
Can't create ActiveX component

(more precisely in Russian: "Не удалось создать компонент ActiveX")
Posted 05 Apr, 2012 17:51:52 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Vadim,

Please take a look at the GetObject or GetActiveObject cannot find a running Office application article. It describes your case:

ActiveX component can't create object


Am I on the right avenue?
.NET, Extended MAPI, Windows Phone & RT
Posted 06 Apr, 2012 08:46:08 Top
Vadim Usmanov




Posts: 18
Joined: 2012-03-23
I use Russian version of VS and I think "Не удалось создать компонент ActiveX" - not quite accurate translation of message "ActiveX component can't create object"
Posted 06 Apr, 2012 09:00:32 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Vadim,

What line of code fires the exception? Are you able to reproduce the issue with a regular windows forms application?

Do you run IE under the Protected Mode? If so, could you please try to turn the Protected Mode off and then close all IE instances. Are you able to reproduce the issue now (with Protected mode turned off)?
.NET, Extended MAPI, Windows Phone & RT
Posted 06 Apr, 2012 09:10:44 Top
Vadim Usmanov




Posts: 18
Joined: 2012-03-23
Hello, Eugene!

Sorry for the long pause and thanks for help.

Eugene Astafiev writes:
Do you run IE under the Protected Mode? If so, could you please try to turn the Protected Mode off and then close all IE instances. Are you able to reproduce the issue now (with Protected mode turned off)?


I turn the IE Protected Mode off and I can get running Excel! But maybe there is a way to get Excel from the Protected Mode?
Posted 24 Apr, 2012 13:34:59 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Vadim,

Nope. Applications (Excel and IE) are run in different integrity levels. Please read more about this in the Windows Vista Integrity Mechanism Technical Reference section in MSDN.
.NET, Extended MAPI, Windows Phone & RT
Posted 25 Apr, 2012 05:01:16 Top