3 Replies Latest reply on Oct 19, 2012 2:37 PM by helgesonc

    Issues installing custom Excel Add-In when PI-DataLink 2010 SP1 is installed

    helgesonc

      Hello,

       

      Not sure exactly where this thread should go, but here is the background:

       

      We have a custom Excel Add-In that we install via InstallShield/InstallScript.  This add-in is completely independent of the PI-DataLink and PI SMT add-ins, though one optional feature we have generates cell formulas to get current PI values (which are then evaluated if possible).

       

      The installation works fine when PI-DataLink 3.x is installed on Excel 2003 and also when PI-DataLink 4.0.x or 4.1.x is installed on Excel 2007.  Our add-in registers properly (per-user install) and can be used immediately after installation.

       

      The problem  occurs when trying to install our add-in when PI-DataLink 4.2.x (aka 2010 with SP1) is installed on Excel 2010 (32bit).  If the PI-DataLink 2010 add-in is disabled (in both the "Excel Add-ins" and "COM Add-Ins" configuration in the Add-Ins window of Excel options), all is well.  When the PI-Datalink 2010 add-in is enabled, our installer finishes just fine but a popup window gives the following prompt:

       

      1258.PITrendXLA-Password-Prompt.png

       

      When clicking the Cancel button, the following error appears:

       

      2465.PITrendXLA-catastrophic-failure.png

       

      When running Excel 2010 after this happens, both PI-DataLink and our Excel add-ins work just fine, but this is not something our users will want to see after installing our add-in.

       

      I'm not sure if the InstallScript code will help, but here it is.  C++ syntax highlighting will make it easier to read, but it's not the same.  None of these error messages are found in the log file after installation.  If OSIsoft doesn't use InstallScript, similar tests can probably be used by making minor edits to this code and translating it to VBScript.

       

       

       
      export prototype ExcelAddIn_Installed();
      function ExcelAddIn_Installed()
           STRING     svAddInFile;
           OBJECT     oXL, oAddIn;
      begin
           svAddInFile = INSTALLDIR ^ EXCEL_ADDIN_FILE;     // path to MyAddin.xla
           if FileExists( svAddInFile ) then
                set oXL = CreateObject( "Excel.Application" );
                if IsObject( oXL ) then
                     try
                          oXL.Workbooks.Add();
                     catch
                          LogFile_AddLine( "Workbooks.Add() failed." );     //debug
                     endcatch;
                     try
                          set oAddIn = oXL.Addins.Add( svAddInFile, TRUE );
                     catch
                          LogFile_AddLine( "Addins.Add( " + svAddInFile + ", TRUE ) failed" );     //debug
                     endcatch;
                     if IsObject( oAddIn ) then
                          try
                               oAddIn.Installed = TRUE;
                          catch
                               MessageBox( "Error registering " + IFX_PRODUCT_NAME + ":\n" + Err.Description, WARNING );
                          endcatch;
                     else
                          LogFile_AddLine( "could not register '" + EXCEL_ADDIN_FILE + "': IsObject( oAddIn ) failed." );
                     endif;
                     try
                          oXL.Workbooks.Close;
                     catch
                          LogFile_AddLine( "there were issues closing workbooks: " + Err.Number + " " + Err.Description );
                     endcatch;
                     try
                          set oAddIn = NOTHING;
                     catch
                          LogFile_AddLine( "there were issues setting oAddIn = NOTHING" );     //debug
                     endcatch;
                     try
                          oXL.Application.Quit;     // close Excel.exe process
                     catch
                          LogFile_AddLine( "there were issues quitting Excel.Application: " + Err.Number + " " + Err.Description );     //debug
                     endcatch;
                     try
                          set oXL = NOTHING;
                     catch
                     endcatch;
                endif;
           else
                MessageBox( "Could not find " + IFX_PRODUCT_NAME + " file to register:\n" + svAddInFile, WARNING );
           endif;
      end;
      

       So I guess the big question is:  what is different about trying to register an Excel add-in when PI-DataLink 4.2.x is installed vs earlier versions?

       

      Thanks,
      Caleb

       

      Side note: Excel 2007 and 2010 tests were both performed on Windows 2008 R2 Enterprise (64bit).

       

       

        • Re: Issues installing custom Excel Add-In when PI-DataLink 2010 SP1 is installed
          helgesonc

          Here is the same code translated into VBScript.  Just change the path and filename to whatever .xla add-in file you want to test.  I have confirmed that there is no issue in Excel 2010 when DataLink 2010 SP1 is not installed and/or not enabled.  The password prompt will show up if DataLink 2010 SP1 is installed and enabled.

           

           

           
          Option Explicit
          
          Err.Clear
          On Error Resume Next
          
          dim INSTALLDIR
          dim EXCEL_ADDIN_FILE
          
          INSTALLDIR = "C:\test\"
          EXCEL_ADDIN_FILE = "MyAddIn.xla"
          
          dim svAddInFile
          dim oXL, oAddIn
          dim filesys
          Set filesys = CreateObject("Scripting.FileSystemObject") 
          
          svAddInFile = INSTALLDIR & EXCEL_ADDIN_FILE    ' path to MyAddin.xla
          if filesys.FileExists( svAddInFile ) then
               set oXL = CreateObject( "Excel.Application" )
               if IsObject( oXL ) then
                    oXL.Workbooks.Add()
                    if Err.Number <> 0 then
                         MsgBox( "Workbooks.Add() failed." )   'debug
                    end if
                    if Err.Number = 0 then
                         set oAddIn = oXL.Addins.Add( svAddInFile, TRUE )
                         if Err.Number <> 0 then
                              MsgBox( "Addins.Add( " & svAddInFile & ", TRUE ) failed" )    'debug
                         end if
                    end if
                    if Err.Number = 0 then
                         if IsObject( oAddIn ) then
                              oAddIn.Installed = TRUE
                              if Err.Number <> 0 then
                                   MsgBox( "Error registering add-in:" & vbCrLf & Err.Description )
                              end if
                         else
                              MsgBox( "could not register '" & EXCEL_ADDIN_FILE & "': IsObject( oAddIn ) failed." )
                         end if
                    end if
                    if Err.Number = 0 then
                         oXL.Workbooks.Close
                         if Err.Number <> 0 then
                              MsgBox( "there were issues closing workbooks: " & Err.Number & " " & Err.Description )
                         end if
                    end if
                    if Err.Number = 0 then
                         set oAddIn = NOTHING
                         if Err.Number <> 0 then
                              MsgBox( "there were issues setting oAddIn = NOTHING" )    'debug
                         end if
                    end if
                    Err.Clear
                    oXL.Application.Quit   ' close Excel.exe process
                    if Err.Number <> 0 then
                         MsgBox( "there were issues quitting Excel.Application: " & Err.Number & " " & Err.Description )    'debug
                    end if
                    set oXL = NOTHING
                    MsgBox( "Add-In registered successfully!" )     'debug
               end if
          else
               MsgBox( "Could not find add-in file to register:" & vbCrLf & svAddInFile )
          end if
          

          Sincerely,
          Caleb