Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Session Times

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Session Times

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Session Times

Private Sub Workbook_Open()
Sheets("Sheet1").Range("A1").Formula = "=now()"
Sheets("Sheet1").Range("A2").Value = Now
Sheets("Sheet1").Range("A3").Formula = "=a1-a2"
Sheets("Sheet1").Range("A3").NumberFormat = "h:mm:ss;@"
End Sub

Whenever the worksheet is calculated, A3 will display the session time.
--
Gary''s Student - gsnu200794


"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Session Times

Just a thought, but wouldn't the workbook need to be saved to retain the
values?

--
Regards,
Tom Ogilvy


"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Session Times

That's true and on reflectiion I think my interpretation of "has been used"
is not what the op was wanting. Gary's solution is of course on the mark for
the current session which is most probably what was required though it does
not provide for history.

Geoff K

"Tom Ogilvy" wrote:

Just a thought, but wouldn't the workbook need to be saved to retain the
values?

--
Regards,
Tom Ogilvy


"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Session Times

Another solution as it fits your criteria (in a cell) can be found here with
Bob Philip's respons
http://www.microsoft.com/communities...6-35646daae260

hth

Geoff K

"Geoff K" wrote:

That's true and on reflectiion I think my interpretation of "has been used"
is not what the op was wanting. Gary's solution is of course on the mark for
the current session which is most probably what was required though it does
not provide for history.

Geoff K

"Tom Ogilvy" wrote:

Just a thought, but wouldn't the workbook need to be saved to retain the
values?

--
Regards,
Tom Ogilvy


"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Session Times

Geoff,

The code worked OK, however both times are current (the same). I was
thinking after I wrote in, it would be great to have a ticking clock in range
B1:B2 to let the user know how long the session is taking. The range A1:A2
(start of session) works great. I need to get the user thinking how long
he/she is spending on 1 job.

The history does not matter, and the session time need not be archived,
although it would help.

Thanks





"Geoff K" wrote:

try something like this

put this into your ThisWorkBook module
Private Sub Workbook_Open()
With Sheets(1)
.Range("A1") = "Wbook opened at:"
.Range("A2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
With Sheets(1)
.Range("B1") = "Last closed at:"
.Range("B2") = Format(Now, "dd/mm/yyyy hh:mm:ss")
End With
End Sub

hth

Geoff K

"will07" wrote:

Hello All,

Is it possible to add some code into a file that will show the session time
(in a cell)that a file is open or has been used.

thanks

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
Macro to run RDP session alistew Excel Discussion (Misc queries) 0 February 22nd 08 11:27 AM
Startup and template locations in Citrix TS session and local session John Nurick Setting up and Configuration of Excel 2 September 21st 06 10:42 PM
Global session Alvin Excel Programming 2 July 26th 06 07:33 AM
Ending session Freddie Mac Excel Programming 11 June 30th 06 01:04 PM
Start a new session when a session is already opend MD Excel Programming 1 December 17th 05 05:47 PM


All times are GMT +1. The time now is 11:20 AM.

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

About Us

"It's about Microsoft Excel"