Username's almost there!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Many thanks to Bob and Chip for blind-piloting me this far, your patience is impressive — in particular, Bob's step-by-step for dummies was exactly what I needed
The code doesn't stop the (falsifiable) Username from Options from appearing in the Track Changes list. However, I can now get the logged-on user name to appear in a cell, from which a macro picks it up, pastes value only to an adjacent cell and copies it from there into the Username box.
Now all I need is for this macro to run every time the workbook is saved. As Track Changes only picks up what has been saved, this should do the trick
So please could you help me this little bit further? How can I tell a macro to run at the point of saving, instead of just from a button or whatever
Hopefully
teabag.
 
teabag,

Call your macro from the Workbook_BeforeSave event.

FRom the VBA editor, double click on "ThisWorkbook" in the
"Projects" window.

Copy and paste the following in the panel on the right
substituting your macro name for "yourmacroname"

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
yourmacroname
End Sub

John

teabag said:
Many thanks to Bob and Chip for blind-piloting me this far, your patience
is impressive - in particular, Bob's step-by-step for dummies was exactly
what I needed!
The code doesn't stop the (falsifiable) Username from Options from
appearing in the Track Changes list. However, I can now get the logged-on
user name to appear in a cell, from which a macro picks it up, pastes value
only to an adjacent cell and copies it from there into the Username box.
Now all I need is for this macro to run every time the workbook is saved.
As Track Changes only picks up what has been saved, this should do the
trick.
So please could you help me this little bit further? How can I tell a
macro to run at the point of saving, instead of just from a button or
whatever?
 
Thanks for that, John. Guess I did something wrong as it does not work. I get a syntax error. Wonder if it is because there is already a bit of code in there from the previous advice (picking up the log-in name) from Bob Phillips, i.e.

Private Sub Workbook_Open(
Application.UserName = UserName(
End Su

I simply put yours in after that. When it didn't work, I cut and pasted it before this text. Still no joy
Maybe I have to link them somehow? Or separate them
I guess that's why it isn't working, anyway..

Please help further if anyone has a moment, thanks

teabag.
 
teabag,

You have to watch out for wordwrap:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

The above should be all on one line.

John

teabag said:
Thanks for that, John. Guess I did something wrong as it does not work. I
get a syntax error. Wonder if it is because there is already a bit of code
in there from the previous advice (picking up the log-in name) from Bob
Phillips, i.e.
Private Sub Workbook_Open()
Application.UserName = UserName()
End Sub

I simply put yours in after that. When it didn't work, I cut and pasted it
before this text. Still no joy.
 
Back
Top