Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

    //initialize excel objects
    //FileName is passed in from the calling function which is loaded via
    // an ini file with this value "R:\Production_Test_Files\Command_Scripts\Bootload_Test.xls"
    //When I view this value while the code is running, it changes the "\" to "\\"
    string ExWorkBook = FileName;

    //if I uncomment the next line there are no problems.
    //ExWorkBook = "R:\\Production_Test_Files\\Command_Scripts\\Bootload_Test.xls";

    Excel.Application oApp = new Excel.Application();
    //CRASHES next line with 'File not found error', NOTE: the Gap in the value is not present in the IDE...
    Excel.Workbook oWB = oApp.Workbooks.Open(ExWorkBook,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value);

    //Cleanup:  
    GC.Collect();
    GC.WaitForPendingFinalizers();

    oWB.Close(false,Missing.Value,Missing.Value); //Save changes = false
    Marshal.FinalReleaseComObject(oWB);
    oWB = null;
           
    oApp.Quit();
    Marshal.FinalReleaseComObject(oApp);
    oApp = null;

 

I have an application that reads values in from an XL spread sheet. If I pass a network path in that I read from an INI file, I get a file cannot be found error. If I place the same value into the variable locally the file opens reads and then closes just fine. I am using .net 2005.

 

MTS

"Beer is proof that God loves us and wants us to be happy."

-Benjamin Franklin

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...