Hi There,
I have a rather large and cumbersome program. I have two questions!
Version:
Excel 2016
The problem:
When the workbook containing my program is open (we'll call it "Program Workbook"), if I open any other file in Excel, it triggers the CALCULATE event from ThisWorkbook sheet of the "Program Workbook".
I regularly need to open (.xml) files from emails. When I open these files, they are opened as Read-only.
in the CALCULATE event, I use the reference
Trying to execute this line is producing the error message:
vba excel run-time error '91':
Object variable or With block variable not set.
I want to avoid this so that I don't need to shut down the Program Workbook every time I wish to open a read-only sheet (which is regularly!). I also don't wish to copy the file from the email to the desktop and then open it.
(I am effectively using this to ensure that the "Program Workbook" is the active workbook (by checking if activeworkbook.name = thisworkbook.name)
So the question is,
Can I capture the name of the read-only file that has just opened by a different method, or can I check to see if the activeworkbook is read-only to avoid the above error?
(checking
produces the same error).
Alternatively, can I avoid the error by a different check to protect this line from fateful execution?!
I wonder as the file is trying to open, perhaps there is no activeworkbook at that moment?
As a secondary question, I wouldn't have thought that opening a different workbook would have triggered the CALCULATE event on the "Program Workbook" ThisWorkbook sheet. Should this be the case? If not, what could be triggering it? There is nothing in "Personal.xlsb" ThisWorkbook sheet.
I would appreciate any comments that might guide me in the correct direction!
additional info (which I don't think is required, but may throw some light on the subject)
I need the CALCULATE event in The Program in order to perform an operation on one of the sheets within the workbook.). I have used volatile data (the
function and also formulae to trigger the CALCULATE event when anything about specific sheets are changed)
Bookmarks