Help With Referencing File Names with Spaces in Them



I am trying to have a sheet withing a workbook keep a log of who opens
a workbook and when. I believe I'm running into problems because the
workbook name has spaces in it. The code that I'm trying to use is

Private Sub Workbook_Open (file with spaces in it.xls)
Dim LastRow As Long
LastRow = Sheets("Log").Range("A65000").End(xlUp).Row
Sheets("Log").Cells(LastRow + 1, 1).Value = Now
Sheets("Log").Cells(LastRow + 1, 2).Value = Application.UserName
End Sub

And the error i receive when I try to use this code is

Compile error:

Expected: list separator or )

The other code I tried to plug in was

Private Sub Workbook_Open ("file with spaces in it.xls")
Dim LastRow As Long
LastRow = Sheets("Log").Range("A65000").End(xlUp).Row
Sheets("Log").Cells(LastRow + 1, 1).Value = Now
Sheets("Log").Cells(LastRow + 1, 2).Value = Application.UserName
End Sub

and the error I received was.

Compile error:

Expected: indentifier

I'm sure there is an easy solution to my little problem, but I've
just started fooling around with VBA and after searching for the last
couple of weeks I've admitted I need to ask for help. So, thank you
for any help any of you can send my way.

.



Relevant Pages

  • RE: How to backup excel files?
    ... VBE WORKBOOK WINDOW ... Private Sub Workbook_BeforeClose ... This can be used in any workbook, and will name the backup according to the ...
    (microsoft.public.excel.programming)
  • Re: Listbox rowsource on Userform
    ... Is your data in the same workbook as the userform? ... Private Sub UserForm_Initialize ... Dim LastRow As Long ... set wkbk = workbooks ...
    (microsoft.public.excel.misc)
  • Re: Listbox rowsource on Userform
    ... Private Sub UserForm_Initialize ... 'or if the data was in the same workbook as the userform ... I'm trying to set the rowsource of a listbox, ... Dim LastRow as String ...
    (microsoft.public.excel.misc)
  • Re: Blinking Text
    ... Compile Error: ... Private Sub Workbook_BeforeClose ... All i get in MY workbook here, ... Did you get a message about enabling macros when you opened the workbook I sent? ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Blinking Text
    ... the same places as I do in my workbook, ... Sub StartBlinking() ... Private Sub Workbook_BeforeClose ... that stops the compile error thing coming up and seems to be ok, ...
    (microsoft.public.excel.worksheet.functions)