need logging before closing the workbook.

  • Thread starter Thread starter Martyn
  • Start date Start date
Hi Frank,

I am totally confused too...Also am starting to feel like a fool!
The problem occurs while it's checking if the log file is open and open it
if not...
So the macro is not even getting to the line related with the msgbox...
Problem happens before that...Here:
--------------
'check if logging workbook is open / if not open it
On Error Resume Next
Set log_wbk = Workbooks(log_filename)
On Error GoTo 0
--------------
The error message I receive is exactly this:
Run-time error '9'
Subscript out of range

And the VBA editor highlights the line

Set log_wbk = Workbooks(log_filename)

Hope we can get somewhere now.
Cheers
Martyn
 
Hi Marty
now i see but this line should not throw an error (as this should be
prevented by the line: 'on error resume next'). As a workaround you may
comment these 3 lines (if you're sure that the log.xls file is not
opened manually by a user). Your code should work then. But I'm still
curious why this error is not catched by the 'on error resume next'
line.
 
Hi Frank,
Funny but when I comment these 3 lines everything worked smootly.
The msgbox indicated the log path & name OK.
The macro saved the content to the log file.
Thanks for all the info and patience with me.:)
Martyn
 
Back
Top