Locked Excel-Start with VB.NET with all AddIns

  • Friday, November 25, 2011 7:55 AM
     
     

    Hello,

    when i start a Excel session with VB.NET like

    Dim xlApp As New Microsoft.Office.Interop.Excel.Application 
    xlApp.Visible = True

    the Applikation starts without all AddIns.

    If i start Excel normal(-->Programms --> MircrosoftOffice --> Excel) all AddIns started!

    How can i realize a "normal" - Start with VB.NET?

    Friendly regards

    • Edited by messerle Friday, November 25, 2011 8:00 AM
    •  

All Replies

  • Monday, November 28, 2011 11:33 AM
    Moderator
     
     Answered Has Code

    Hi Messerle,

    Welcome to the MSDN Forum.

    To load the addins, you need more lines code to achieve it.

    Here is more details about this issue: http://support.microsoft.com/kb/213489

    Here is a code snippet of .net version:

            Dim Exl As New Excel.Application()
            ' Open the add-in file you want, in this example, XLQUERY.XLAM.
            Exl.Workbooks.Open(Exl.LibraryPath & "\MSQUERY\XLQUERY.XLAM")
    
            ' Open the add-in file you want, in this example, XLQUERY.XLA.
            Exl.Workbooks.Open(Exl.LibraryPath & "\MSQUERY\XLQUERY.XLA")
    

    I hope this will be helpful.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Tuesday, November 29, 2011 7:42 AM
     
     Answered Has Code

    Hello Mike,

    thank you for the solution.

    Meanwhile i found a solution where Excel starts with all included AddIns like the "normal" Application-Start.

    Here is a code-snippet with my solution in VB.NET:

    Imports Microsoft.Office.Interop
    Imports System.Runtime.InteropServices.Marshal
    
    Module Module1
    
    Sub Main()
    Dim xlApp As Microsoft.Office.Interop.Excel.Application
    Dim xlWb As Excel.Workbook = Nothing
    Dim xlWbc As Excel.Workbook = Nothing
    Dim xlSh As Excel.Worksheet = Nothing
    Dim startInfo As New ProcessStartInfo
    Dim xlDummy As String = "Path and Filename of an Excelsheet" 	'Dummyfile without any Data
    Dim proc As Process = Nothing
     
    startInfo.FileName = "EXCEL.EXE"
    startInfo.Arguments = xlDummy
    proc = Process.Start(startInfo)
    xlWbc = BindToMoniker(xlDummy)
    xlApp = xlWbc.Parent
    xlApp.Workbooks.Add()		'Add or Open the File you need to do something
    xlApp.Visible = True

     

    Best regards, messerle

     

  • Tuesday, November 29, 2011 8:50 AM
    Moderator
     
     

    Hi Messerle,

    Thank you for sharing the solution here.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.