ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Auto macro in Excel help (https://www.excelbanter.com/excel-discussion-misc-queries/65620-auto-macro-excel-help.html)

sacrum

Auto macro in Excel help
 
Hi all,

I have a workbook with multiple sheets. I want the sheet 1 always to
display first and is there a method to display the current user name which
updates it self automatically when different users use the book when its on
a share - I'm thinking of setting up a log. I've done the following as a
test but its not really what I want - ideally there would be a text box that
auto changes without it having to be clicked.

Sub logontest()
Worksheets("Frontscreen").Activate
Dim x
Set x = CreateObject("WSCRIPT.Network")
Dim u
u = x.UserName



'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Current Logon : " & u
End Sub



Tom Ogilvy

Auto macro in Excel help
 
Call you code from the workbook_open event

http://www.cpearson.com/excel/events.htm

Chip Pearson's page on events.

--
Regards,
Tom Ogilvy

"sacrum" wrote in message
...
Hi all,

I have a workbook with multiple sheets. I want the sheet 1 always to
display first and is there a method to display the current user name which
updates it self automatically when different users use the book when its

on
a share - I'm thinking of setting up a log. I've done the following as a
test but its not really what I want - ideally there would be a text box

that
auto changes without it having to be clicked.

Sub logontest()
Worksheets("Frontscreen").Activate
Dim x
Set x = CreateObject("WSCRIPT.Network")
Dim u
u = x.UserName



'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Current Logon : " & u
End Sub





sacrum

Auto macro in Excel help
 

"Tom Ogilvy" wrote in message
...
Call you code from the workbook_open event

http://www.cpearson.com/excel/events.htm

Chip Pearson's page on events.

--
Regards,
Tom Ogilvy

"sacrum" wrote in message
...
Hi all,

I have a workbook with multiple sheets. I want the sheet 1 always to
display first and is there a method to display the current user name
which
updates it self automatically when different users use the book when its

on
a share - I'm thinking of setting up a log. I've done the following as a
test but its not really what I want - ideally there would be a text box

that
auto changes without it having to be clicked.

Sub logontest()
Worksheets("Frontscreen").Activate
Dim x
Set x = CreateObject("WSCRIPT.Network")
Dim u
u = x.UserName



'update text box "Last Updated:"
ActiveSheet.TextBoxes("txtLogon").Text = "Current Logon : " & u
End Sub



Thanks - now sorted.




All times are GMT +1. The time now is 06:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com