isolutions

register PI dataLink 2014 addin using VB.Net

Discussion created by isolutions on Sep 3, 2014
Latest reply on Sep 4, 2014 by Marcos Vainer Loeff

Hello,  I have the code below that was working fine with datalink 2010. I am having some issues after upgrading to datalink 2014. The code is part of an application that is executed by the task scheduler. For some reason, if I execute the app from CMD it works fine the problems are when I execute it from the task scheduler. At this point, I am not totally sure what is causing the issue but it appears when the code opens an excel workbook. As the issue started appearing after upgrading to datalink 2014, it makes me think that could be related to the datalink add-in registration. 

 

The following code is showing how I am doing the add-in registration for datalink 2010. Should this continue working for datalink 2014 or is there any change in the code the I have to do?

 

 Thanks!

 

 

 
If blnDebug Then _
                objLog.WriteDebugLine("Starting Excel and registering DataLink add-in")
            xlApp1 = New Excel.Application
            blnExcelOpen = True
            xlApp1.RegisterXLL("C:\Program Files (x86)\PIPC\Excel\pipc32.xll") '--->>> Add-in registration


            ' get the Process Id of the Excel application object
            Dim nPntr As IntPtr
            GetWindowThreadProcessId(xlApp1.Hwnd, nPntr)
            nProcessId = nPntr.ToInt32()
            objLog.WriteDebugLine("Excel Process Id : " & nProcessId.ToString())

            'Open the workbook to be read from, run any auto macros and force it to calculate
            If blnDebug Then _
                objLog.WriteDebugLine("Opening the source workbook and updating data")
            xlWB_Read = xlApp1.Workbooks.Open(strReadFile)
            objLog.WriteDebugLine("Workbook opend")    ''*******------->>> Here is where the task scheduler gets stuck. The task keeps running for ever; I have to kill the process.
            xlWB_Read.RunAutoMacros(Excel.XlRunAutoMacro.xlAutoActivate)
            xlWB_Read.RunAutoMacros(Excel.XlRunAutoMacro.xlAutoOpen)
            xlApp1.Calculate()

 

Outcomes