createComObject() in CTRL manager problems

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
1 post • Page 1 of 1
User avatar
aorange
Posts: 147
Joined: Thu Nov 04, 2010 10:07 am

createComObject() in CTRL manager problems

Post by aorange »

Hi Guys,

Sorry to trouble you again with stupid questions but I have ran into a rather strange problem using the createComObject() function and I think I might be a bug. I created a function that calls createComObject() in a library named IPSS.ctl. The function works fine when called from a UI but not when called from a CTRL manager, I keep getting the following error message:

PVSS00ctrl (6), 2010.11.09 10:17:33.468, CTRL, WARNING, 78, Assignment to this expression impossible, IPSS_MiserDataImport.ctl, Count, Function not found

It looks as if PVSS doesn't recognise the "Count" property of the Excel.Application COM object, but the strange thing is that it works fine in a UI manager. I have added my library IPSS.ctl both to the [CTRL] and [UI] sections of my config file. Other functions in the library run fine except for this one. Any ideas??

My function code looks like this:

Code: Select all

int IPSS_ReadExcelFile(string          strFileName, 
                       dyn_dyn_anytype &ddaFileContent)
//*********************************************************************************
// Extract the complete content of the Excel file requirested in the first parameter
// using the COM application interface provided by MS.
// Returns the file content in a dyn_dyn_any_type.
// Arguments required are:
// - strFileName, full path of the file to be extracted
// - ddaFileContent, a dyn_dyn_anytype variable to receive the information
//********************************************************************************* 
{
  DebugFN("IPSS", "** FUNC IPSS_ReadExcelFile **" + strFileName, isfile(strFileName));
  
  if(isfile(strFileName))
  {
    dyn_string dsXlCol;
  
    dsXlCol[1]  = "A";
    dsXlCol[2]  = "B";
    dsXlCol[3]  = "C";
    dsXlCol[4]  = "D";
    dsXlCol[5]  = "E";
    dsXlCol[6]  = "F";
    dsXlCol[7]  = "G";
    dsXlCol[8]  = "H";
    dsXlCol[9]  = "I";
    dsXlCol[10] = "J";
    dsXlCol[11] = "K";
    dsXlCol[12] = "L";
    dsXlCol[13] = "M";
    dsXlCol[14] = "N";
    dsXlCol[15] = "O";
    dsXlCol[16] = "P";
    dsXlCol[17] = "Q";
    dsXlCol[18] = "R";
    dsXlCol[19] = "S";
    dsXlCol[20] = "T";
    dsXlCol[21] = "U";
    dsXlCol[22] = "V";
    dsXlCol[23] = "W";
    dsXlCol[24] = "X";
    dsXlCol[25] = "Y";
    dsXlCol[26] = "Z";
  
    idispatch xl;
    idispatch xlWorkbooks;
    idispatch xlWorkbook;
    idispatch xlWorkSheets;
    idispatch xlWorksheet;
    idispatch xlRange;

    anytype     aRaw;
    dyn_string  dsTimeStamps;
    dyn_float   dfVals;

    int intRows;
    int intColumns;  
  
    /* Open Excel Object */
    xl = createComObject("Excel.Application");   // Create the application interface

    if(xl != 0)  
    {
      xl.visible   = FALSE;                                  // Keep the file hidden from the user
      xlWorkbooks  = xl.Workbooks;                           // Get the Workbooks collection
      xlWorkbook   = xlWorkbooks.Open(strFileName);          // Call the open event (inherited from the WorkbookEvents_Event)
      xlWorkSheets = xl.Worksheets;                          // Get the Worksheets collection
      xlWorksheet  = xlWorkSheets.Item(1);                   // Item is a property inherited from Sheets

      xlRange      = xlWorksheet.UsedRange;
  
      intRows      = xlRange.Rows.Count;                     // Get the number of used rows
      intColumns   = xlRange.Columns.Count;                  // Get the number of used columns
  
      for(int i = 1; i

Post Reply
1 post • Page 1 of 1