View Single Post
  #20   Report Post  
Posted to microsoft.public.excel.programming
Martyn Martyn is offline
external usenet poster
 
Posts: 80
Default need logging before closing the workbook.

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...He
--------------
'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



"Frank Kabel" wrote in message
...
Hi Martyn
now I'm getting desperate :-)
If the path variable is declared as path="C:\"
and the lo´g_filename as
log_filename = "log.xls"

then the code snippet
If log_wbk Is Nothing Then
msgbox path & log_filename
Workbooks.Open filename:=path & log_filename
Set log_wbk = Workbooks(log_filename)
End If

should do. Does this msgbox returns the correct information?. I have
tested this again in my environment and everything works fine - also
took it to another PC - result was also o.k.

--
Regards
Frank Kabel
Frankfurt, Germany