I have been trying to find a solution to having VFP Automation of Excel perform an initial test to check if the Workbook just opened was opened as ReadOnly due to someone else having the file open.
Unfortunately what I have found so far through web searches has not worked.
Originally, based on findings on the web, I was trying the following (but it did not work):
The oExcel.ReadOnly threw an
OLE code error - unknown object
Next by wandering around through the oExcel object properties I thought that I found the answer, but it too did not work:
But oExcel.ThisWorkbook.ReadOnly threw an
OLE IDispatch exception code 0 from Microsoft Excel - Unable to get ThisWorkbook property of the Application class...
I have a strong suspicion that there is a test that I can perform, but I have yet to find the right combination of objects and properties to do the job.
As always, any advice you might have to give would be greatly appreciated.
Thanks,
JRB-Bldr
Unfortunately what I have found so far through web searches has not worked.
Originally, based on findings on the web, I was trying the following (but it did not work):
Code:
tmpsheet = CREATEOBJECT('excel.application')
oExcel = tmpsheet.APPLICATION
oExcel.Workbooks.OPEN(ADDBS(cReportDir) + cExcelFile)
oExcel.WINDOWS(cExcelFile).ACTIVATE
IF [B]oExcel.ReadOnly[/B]
<do something>
ENDIF
The oExcel.ReadOnly threw an
OLE code error - unknown object
Next by wandering around through the oExcel object properties I thought that I found the answer, but it too did not work:
Code:
tmpsheet = CREATEOBJECT('excel.application')
oExcel = tmpsheet.APPLICATION
oExcel.Workbooks.OPEN(ADDBS(cReportDir) + cExcelFile)
oExcel.WINDOWS(cExcelFile).ACTIVATE
IF [B]oExcel.ThisWorkbook.ReadOnly[/B]
<do something>
ENDIF
But oExcel.ThisWorkbook.ReadOnly threw an
OLE IDispatch exception code 0 from Microsoft Excel - Unable to get ThisWorkbook property of the Application class...
I have a strong suspicion that there is a test that I can perform, but I have yet to find the right combination of objects and properties to do the job.
As always, any advice you might have to give would be greatly appreciated.
Thanks,
JRB-Bldr