We have a VB6 application which will open the excel sheet, format and print it. It is working fine in windows XP and windows 2000 server. But getting run-time when the same code is executed in Windows 2008 server(64-bit machine). Error message is,
Server threw an Exception"
Error throws when executing the below BOLDED code.
'If Excel not already loaded, create a new instance of Excel
If mobjExcelReport.MyExcelApp Is Nothing Then
Set mobjExcelReport.MyExcelApp = CreateObject("Excel.Application")
'Load Todays Excel doc
Set mobjExcelReport.MyExcelWorkbook = mobjExcelReport.MyExcelApp.Workbooks.Open(sTargetPath & "\" & sTargetFileName, , , , "abcdef")
Both the windows 2000 server and windows 2008 server has Excel8.0 library.
Any idea on this error would help.
Errors starting with 0x8 are usually permission errors or memory pointers not pointer to a memory location you have permission to access. Try opening the file manually using excel and see if the file will open with the same crediatials the program is using. If the file opens then maybe the variable mobjExcelReport.MyExcelApp is not valid. I would then add a break point on the line that is giving the error by selecting the line with the mouse and pressing F9. then add the variable mobjExcelReport to the watch window by highlighting the variable and right click the mouse selecting "Add Watch". then check to see if both mobjExcelReport and mobjExcelReport.MyExcelApp are not NULL.
Thanks for your detailed info.
I tried the below things as per your comment.
1) Tried opening the excel manually and it worked.
2) Added a watch window for mobjExcelReport.MyExcelApp and it shows as Excel object.
I have attached the screen shots for your referance. But nothing helped.
Without seeing the entire code at this point of time I'm not sure I can help. Two things to try are
1) Make sure all the Excel.exe process are closed before you open you first workbook. Sometimes the excel processes don't shutdown and there are a limit to the nuber of simulataneous excel.exe files that can ber opened at one time. Check the Task Manager.
2) Try making the excel application visible which may give a clue to where the problem is located.
mobjExcelReport.MyExcelApp.visible = true