close

Hi all,

I've created a method to capture current user (network username) and a date
/ time stamp. I want this output to be logged on a hidden sheet called
'log' strangely enough! How does it find the next available line in log to
output to?

tia
see if this will help you. you didn't give too specific of a description, so
hopefully this is what you're looking for

lastRow = Worksheets(quot;logquot;).Cells(Rows.Count, quot;Aquot;).End(xlUp).Row

range(quot;A: amp; lastrow 1) = quot;your date/time stamp codequot;--Garyquot;sacrumquot; gt; wrote in message
...
gt; Hi all,
gt;
gt; I've created a method to capture current user (network username) and a
gt; date / time stamp. I want this output to be logged on a hidden sheet
gt; called 'log' strangely enough! How does it find the next available line
gt; in log to output to?
gt;
gt; tia
gt;

quot;Gary Keramidasquot; lt;GKeramidasATmsn.comgt; wrote in message
...
gt; see if this will help you. you didn't give too specific of a description,
gt; so hopefully this is what you're looking for
gt;
gt; lastRow = Worksheets(quot;logquot;).Cells(Rows.Count, quot;Aquot;).End(xlUp).Row
gt;
gt; range(quot;A: amp; lastrow 1) = quot;your date/time stamp codequot;
gt;
gt;
gt; --
gt;
gt;
gt; Gary
gt;
gt;
gt; quot;sacrumquot; gt; wrote in message
gt; ...
gt;gt; Hi all,
gt;gt;
gt;gt; I've created a method to capture current user (network username) and a
gt;gt; date / time stamp. I want this output to be logged on a hidden sheet
gt;gt; called 'log' strangely enough! How does it find the next available line
gt;gt; in log to output to?
gt;gt;
gt;gt; tia
gt;gt;
gt;
Gary thanks - sorry for not being clear - here is the unworking script:

Private Sub Workbook_open()
Worksheets(quot;Frontscreenquot;).Activate
ActiveSheet.Unprotect

Dim x
Set x = CreateObject(quot;WSCRIPT.Networkquot;)
Dim u
u = x.UserName
t = Time
'update text box quot;Last Updated:quot;
ActiveSheet.TextBoxes(quot;txtLogonquot;).Text = quot;Welcome to IRIS quot; amp; u amp; quot; -
Access Time: quot; amp; t
ActiveSheet.Protectlastrow = Worksheets(quot;logquot;).Cells(Rows.Count, quot;Aquot;).End(xlUp).Row
Loglisting = txtLogon.Value

Worksheets(quot;Logquot;).Range(quot;Aquot; amp; lastrow 1).Value = Loglisting

End Sub
Basically when workbook opens the current user is identified and displayed
using text box. I want this value to be copied to the next available line
in a log worksheet that is hidden from the user.
Since you're creating a log, I would think that you would want to include the
date as well as the time. Although, you may not want to include that in the
textbox.

But something like this may work ok:

Option Explicit
Private Sub Workbook_open()
Dim x As Object
Dim u As String
Dim t As Date
Dim LastRow As Long

Set x = CreateObject(quot;WSCRIPT.Networkquot;)

With Worksheets(quot;FrontScreenquot;)
.Activate
.Unprotect
u = x.UserName
t = Now
'update text box quot;Last Updated:quot;
.TextBoxes(quot;txtLogonquot;).Text _
= quot;Welcome to IRIS quot; amp; u amp; quot; - Access Time: quot; _
amp; Format(t, quot;hh:mm:ssquot;)
.Protect
End With

With Worksheets(quot;Logquot;)
LastRow = Worksheets(quot;logquot;).Cells(.Rows.Count, quot;Aquot;).End(xlUp).Row
With .Cells(LastRow 1, quot;Aquot;)
.Value = u
With .Offset(0, 1)
.Value = t
.NumberFormat = quot;mm/dd/yyyy hh:mm:ssquot;
End With
End With
End With

End Sub

I also put the name and date/time in two different columns.

Remember that this log entry will be lost if the workbook is closed without
saving.

sacrum wrote:
gt;
gt; quot;Gary Keramidasquot; lt;GKeramidasATmsn.comgt; wrote in message
gt; ...
gt; gt; see if this will help you. you didn't give too specific of a description,
gt; gt; so hopefully this is what you're looking for
gt; gt;
gt; gt; lastRow = Worksheets(quot;logquot;).Cells(Rows.Count, quot;Aquot;).End(xlUp).Row
gt; gt;
gt; gt; range(quot;A: amp; lastrow 1) = quot;your date/time stamp codequot;
gt; gt;
gt; gt;
gt; gt; --
gt; gt;
gt; gt;
gt; gt; Gary
gt; gt;
gt; gt;
gt; gt; quot;sacrumquot; gt; wrote in message
gt; gt; ...
gt; gt;gt; Hi all,
gt; gt;gt;
gt; gt;gt; I've created a method to capture current user (network username) and a
gt; gt;gt; date / time stamp. I want this output to be logged on a hidden sheet
gt; gt;gt; called 'log' strangely enough! How does it find the next available line
gt; gt;gt; in log to output to?
gt; gt;gt;
gt; gt;gt; tia
gt; gt;gt;
gt; gt;
gt; Gary thanks - sorry for not being clear - here is the unworking script:
gt;
gt; Private Sub Workbook_open()
gt; Worksheets(quot;Frontscreenquot;).Activate
gt; ActiveSheet.Unprotect
gt;
gt; Dim x
gt; Set x = CreateObject(quot;WSCRIPT.Networkquot;)
gt; Dim u
gt; u = x.UserName
gt; t = Time
gt; 'update text box quot;Last Updated:quot;
gt; ActiveSheet.TextBoxes(quot;txtLogonquot;).Text = quot;Welcome to IRIS quot; amp; u amp; quot; -
gt; Access Time: quot; amp; t
gt; ActiveSheet.Protect
gt;
gt; lastrow = Worksheets(quot;logquot;).Cells(Rows.Count, quot;Aquot;).End(xlUp).Row
gt; Loglisting = txtLogon.Value
gt;
gt; Worksheets(quot;Logquot;).Range(quot;Aquot; amp; lastrow 1).Value = Loglisting
gt;
gt; End Sub
gt; Basically when workbook opens the current user is identified and displayed
gt; using text box. I want this value to be copied to the next available line
gt; in a log worksheet that is hidden from the user.

--

Dave Peterson

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()