I have a program that reads MS Excel spreadsheets and it works fine when running on workstations. I lost my development system and the new one now uses Windows Server 2012 and no longer is able to read the spreadsheet. I am running Net Express 5.1
#Excel#Server2012Can you please provide more detail as to what you mean by you cannot read the spreadsheet?
How are you reading the spreadsheet in your program?
If you are using the native OLE class library syntax like:
class-control.
MSExcel is class "$OLE$Excel.Application".
*> Create a new instance of Microsoft Excel
invoke MSExcel "new" returning ExcelObject
*> Make Excel visible
invoke ExcelObject "setVisible" using by value 1
Then you will have to install the Microsoft Office Excel components on the Server machine.
The required registered COM library would be named something like: Microsoft Excel nn.n Object Library where nn.n is the version of Excel.
Thanks
Can you please provide more detail as to what you mean by you cannot read the spreadsheet?
How are you reading the spreadsheet in your program?
If you are using the native OLE class library syntax like:
class-control.
MSExcel is class "$OLE$Excel.Application".
*> Create a new instance of Microsoft Excel
invoke MSExcel "new" returning ExcelObject
*> Make Excel visible
invoke ExcelObject "setVisible" using by value 1
Then you will have to install the Microsoft Office Excel components on the Server machine.
The required registered COM library would be named something like: Microsoft Excel nn.n Object Library where nn.n is the version of Excel.
Thanks
Yes, that is the syntax that I use. I hate to appear stupid, but this isn't something that I know how to do. This is for Excel 2007. Any help would be appreciated.
Thank you.
Yes, that is the syntax that I use. I hate to appear stupid, but this isn't something that I know how to do. This is for Excel 2007. Any help would be appreciated.
Thank you.
What is the error that you are actually receiving in your program?
Do you have Excel installed directly on this server?
What is the error that you are actually receiving in your program?
Do you have Excel installed directly on this server?
These are the commands that I run.
invoke MSExcel "new" returning ExcelObject
invoke ExcelObject "setVisible" using by value 0.
invoke ExcelObject "getWorkBooks"
returning WorkBooksCollection
*> Open a specific spreadsheet file
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
I attached the message as a JPG
Thanks again.
These are the commands that I run.
invoke MSExcel "new" returning ExcelObject
invoke ExcelObject "setVisible" using by value 0.
invoke ExcelObject "getWorkBooks"
returning WorkBooksCollection
*> Open a specific spreadsheet file
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
I attached the message as a JPG
Thanks again.
Oh, I forgot, yes, it is installed on the server. Windows 2012.
Oh, I forgot, yes, it is installed on the server. Windows 2012.
On which statement is the error occurring?
The error indicates that a 114 error occurs in the NX Exception handler class. This normally indicates a memory or parameter passing problem.
When you execute the following is there a value returned in ExcelObject?
invoke MSExcel "new" returning ExcelObject
Can you show me what the MSExcel definition looks like under Class-control?
Do you know what wrappack level you have installed for Net Express?
On which statement is the error occurring?
The error indicates that a 114 error occurs in the NX Exception handler class. This normally indicates a memory or parameter passing problem.
When you execute the following is there a value returned in ExcelObject?
invoke MSExcel "new" returning ExcelObject
Can you show me what the MSExcel definition looks like under Class-control?
Do you know what wrappack level you have installed for Net Express?
The WrapPack is #11.
Yes, I do get values returned when I invoke "new".
The Class-Control has the following entry: MSExcel is class "$OLE$Excel.Application"
It is this statement that causes the eror.
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
The WrapPack is #11.
Yes, I do get values returned when I invoke "new".
The Class-Control has the following entry: MSExcel is class "$OLE$Excel.Application"
It is this statement that causes the eror.
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
What is the value of d-Excel-File-Name at the time the Open method is invoked?
It should point to an actual excel file on disk:
Example:
01 d-Excel-File-Name pic x(256) value z"C:\\temp\\myexcel\\xlsx".
Note that it uses the null terminator z string literal as Excel expects the name to be null terminated.
Does your file exist on disk in the location your program specifies?
What is the value of d-Excel-File-Name at the time the Open method is invoked?
It should point to an actual excel file on disk:
Example:
01 d-Excel-File-Name pic x(256) value z"C:\\temp\\myexcel\\xlsx".
Note that it uses the null terminator z string literal as Excel expects the name to be null terminated.
Does your file exist on disk in the location your program specifies?
Yes, it does exist and it does point to the files directly. "C:\\RND60\\base\\Apollo Inventory Master.xlsx" .
I do have a routine that puts a null terminator at the end of the file name.
perform varying ix from 255 by -1 until ix < 1
if d-Excel-File-Name(ix:1) not = " "
add 1 to ix
MOVE X"00" TO d-Excel-File-Name(ix:1)
move 1 to ix
end-if
end-perform
Yes, it does exist and it does point to the files directly. "C:\\RND60\\base\\Apollo Inventory Master.xlsx" .
I do have a routine that puts a null terminator at the end of the file name.
perform varying ix from 255 by -1 until ix < 1
if d-Excel-File-Name(ix:1) not = " "
add 1 to ix
MOVE X"00" TO d-Excel-File-Name(ix:1)
move 1 to ix
end-if
end-perform
So I setup a VM that has the following installed:
Windows Server 2012 R2
Office Professional 2007
Server for COBOL 5.1 with Update 11
I created a test program that actually uses the exact location and name of your Excel file.
My demo works fine and I can open the Workbook without a problem.
The demo also checks that the objects being used are not null after they are created.
Can you please compile this demo program and try running it on your system?
$set ooctrl( P)
class-control.
MSExcel is class "$OLE$Excel.Application".
working-storage section.
01 ExcelObject object reference.
01 WorkBooksCollection object reference.
01 WorkBook object reference.
01 d-Excel-File-Name pic x(256)
value z"C:\\RND60\\base\\Apollo Inventory Master.xlsx".
01 any-key pic x.
procedure division.
*> Create a new instance of Microsoft Excel
invoke MSExcel "new" returning ExcelObject
if ExcelObject = null
display "Excelobject = null"
else
display "open ok"
end-if
*> Make Excel visible
invoke ExcelObject "setVisible" using by value 1
*> Get the collection of WorkBooks
invoke ExcelObject "getWorkBooks"
returning WorkBooksCollection
if WorkBooksCollection = null
display "WorkbooksCollection = null"
else
display "getWB ok"
end-if
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
if Workbook = null
display "Workbook = null"
else
display "WB open ok"
end-if
*> Close the WorkBook, discarding the contents
invoke WorkBook "Close" using by value 0
invoke WorkBook "finalize" returning WorkBook
invoke WorkBooksCollection "finalize"
returning WorkBooksCollection
*> Exit Excel
invoke ExcelObject "Quit"
invoke ExcelObject "Finalize" returning ExcelObject
accept any-key
stop run.
So I setup a VM that has the following installed:
Windows Server 2012 R2
Office Professional 2007
Server for COBOL 5.1 with Update 11
I created a test program that actually uses the exact location and name of your Excel file.
My demo works fine and I can open the Workbook without a problem.
The demo also checks that the objects being used are not null after they are created.
Can you please compile this demo program and try running it on your system?
$set ooctrl( P)
class-control.
MSExcel is class "$OLE$Excel.Application".
working-storage section.
01 ExcelObject object reference.
01 WorkBooksCollection object reference.
01 WorkBook object reference.
01 d-Excel-File-Name pic x(256)
value z"C:\\RND60\\base\\Apollo Inventory Master.xlsx".
01 any-key pic x.
procedure division.
*> Create a new instance of Microsoft Excel
invoke MSExcel "new" returning ExcelObject
if ExcelObject = null
display "Excelobject = null"
else
display "open ok"
end-if
*> Make Excel visible
invoke ExcelObject "setVisible" using by value 1
*> Get the collection of WorkBooks
invoke ExcelObject "getWorkBooks"
returning WorkBooksCollection
if WorkBooksCollection = null
display "WorkbooksCollection = null"
else
display "getWB ok"
end-if
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
if Workbook = null
display "Workbook = null"
else
display "WB open ok"
end-if
*> Close the WorkBook, discarding the contents
invoke WorkBook "Close" using by value 0
invoke WorkBook "finalize" returning WorkBook
invoke WorkBooksCollection "finalize"
returning WorkBooksCollection
*> Exit Excel
invoke ExcelObject "Quit"
invoke ExcelObject "Finalize" returning ExcelObject
accept any-key
stop run.
I get the same error as before when it hits this statement:
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
I get the same error as before when it hits this statement:
invoke WorkbooksCollection "Open"
using d-Excel-File-Name
returning Workbook.
It appears like it may be an issue with this specific .xlsx file or its location..
Can you create a very basic Excel file and try to open it using the test program?
It appears like it may be an issue with this specific .xlsx file or its location..
Can you create a very basic Excel file and try to open it using the test program?
Thanks for all you help. I have gone another route and not using Excel at all. That file that i was using was a simple file, all data and no formulas or anything like that.