Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Help With Referencing File Names with Spaces in Them

These kinds of events are built into excel--you can't change how they're
defined.

Just use this in your ThisWorkbook module:
Private Sub Workbook_Open()

But remember that if the suer doesn't save, then the changes to the log will be
lost.


wrote:

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.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Matching names and inserting spaces ILunacy Excel Worksheet Functions 0 February 15th 10 06:15 PM
Matching names and inserting spaces ILunacy Excel Worksheet Functions 3 February 15th 10 03:17 PM
Open Excel file get error with file names that have spaces in the Kozmo Setting up and Configuration of Excel 6 October 29th 08 02:51 AM
Formulas referencing a spaces instead of number ? Ainsley Excel Discussion (Misc queries) 4 May 3rd 06 02:00 PM
Spaces in sheet names Minilek Excel Programming 2 July 13th 04 07:11 AM


All times are GMT +1. The time now is 08:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"