VBA for Excel and COM-handles

Hi,

I’m trying to launch a VBA for Excel from our Progress application, and I’m encountering a problem when I’m testing for access privileges. Essentially, I’m checking the read-only property for the workbook and alert the user if it’s true. Here’s a portion of the code:

DEF VAR chFileName AS CHAR INIT "N:\TestRegion2\testvba.xls" NO-UNDO.

DEF VAR chExcel AS com-handle no-undo.
DEF VAR chWorkbook AS com-handle no-undo.
DEF VAR chExcelApplication AS com-handle no-undo.
DEF VAR chWorksheet AS com-handle no-undo.

CREATE "Excel.Application" chExcel.

chWorkbook = chExcel:Workbooks:open(chFileName).

message "Read only status: " + chWorkbook:ReadOnly view-as alert-box.

As the user completes the form and clicks submit, this error message pops up:
“Error occurred while accessing component property/method: ReadOnly.
Error code:0x800a01a8 c:\windows\temp\p20922_COMtester.cmp(5890)”

From what it looks like, the read-only property is checked after the user completes form, which defeats the purpose of the check. Unless, I’m mistaken, but it seems that I can’t access the read-only property before the file is opened. Is there a better way of doing this? Thanks in advance for the help.

Regards,

Kent