A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

User name in Footer



 
 
Thread Tools Display Modes
  #1  
Old March 30th, 2005, 06:27 PM
Brian Allen - McKEOWN INC.
external usenet poster
 
Posts: n/a
Default User name in Footer

I'm trying to put the user name in a footer and can't figure it out.

I want "This file was prepared by 'username' on &[Date} at &[Time].". But I
can't get the username in there. I've tried everything I can think of from
system variables to system variables with an & and things that just shouldn't
work (and didn't).

Any help would be greatly appreciated.
  #2  
Old March 30th, 2005, 06:32 PM
Chip Pearson
external usenet poster
 
Posts: n/a
Default

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was prepared by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't figure it
out.

I want "This file was prepared by 'username' on &[Date} at
&[Time].". But I
can't get the username in there. I've tried everything I can
think of from
system variables to system variables with an & and things that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.



  #3  
Old March 30th, 2005, 06:49 PM
Brian Allen - McKEOWN INC.
external usenet poster
 
Posts: n/a
Default

Chip,

Thanks for the info, but copying and pasting that didn't work..as I didn't
think it would. I don't have any VBA background and I'm presuming that it is
VBA.

Any other ideas or how can I make this work with my little programming
knowledge?

Thanks again!

"Chip Pearson" wrote:

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was prepared by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't figure it
out.

I want "This file was prepared by 'username' on &[Date} at
&[Time].". But I
can't get the username in there. I've tried everything I can
think of from
system variables to system variables with an & and things that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.




  #4  
Old March 30th, 2005, 07:26 PM
Dave Peterson
external usenet poster
 
Posts: n/a
Default

Open your workbook.
rightclick on the excel icon at the left of File (in the worksheet menubar).
Select view code.
Paste this in the code window that opens.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Worksheets("sheet1").PageSetup.CenterFooter _
= "This file was prepared by " & Environ("username") & " on &D at &T"
End Sub

Chip used the Activesheet. I specified just one sheet (sheet1). I'm not sure
what you want.

Then back to excel and hit the file|print preview button.



Brian Allen - McKEOWN INC. wrote:

Chip,

Thanks for the info, but copying and pasting that didn't work..as I didn't
think it would. I don't have any VBA background and I'm presuming that it is
VBA.

Any other ideas or how can I make this work with my little programming
knowledge?

Thanks again!

"Chip Pearson" wrote:

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was prepared by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't figure it
out.

I want "This file was prepared by 'username' on &[Date} at
&[Time].". But I
can't get the username in there. I've tried everything I can
think of from
system variables to system variables with an & and things that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.





--

Dave Peterson
  #5  
Old March 30th, 2005, 07:29 PM
Chip Pearson
external usenet poster
 
Posts: n/a
Default

Press ALT+F11 to open the VBA Editor, the press CTRL+R to view
the Project Explorer. This will display a tree view window on the
left side of the VBA screen. Find your workbook in the tree
view, expand that node, and expand the "Microsoft Excel Objects"
node. Double click the ThisWorkbook to open that code module. In
that code module, paste the following code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "This file was prepared by "
& _
Environ("username") & " on &D at &T"
End Sub

Close the VBA Editor from the File menu. This code will execute
automatically when you print the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
Chip,

Thanks for the info, but copying and pasting that didn't
work..as I didn't
think it would. I don't have any VBA background and I'm
presuming that it is
VBA.

Any other ideas or how can I make this work with my little
programming
knowledge?

Thanks again!

"Chip Pearson" wrote:

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was prepared
by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't figure
it
out.

I want "This file was prepared by 'username' on &[Date} at
&[Time].". But I
can't get the username in there. I've tried everything I
can
think of from
system variables to system variables with an & and things
that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.






  #6  
Old March 30th, 2005, 09:31 PM
Brian Allen - McKEOWN INC.
external usenet poster
 
Posts: n/a
Default

Thank you both (Dave and Chip). Much appreciated.

"Chip Pearson" wrote:

Press ALT+F11 to open the VBA Editor, the press CTRL+R to view
the Project Explorer. This will display a tree view window on the
left side of the VBA screen. Find your workbook in the tree
view, expand that node, and expand the "Microsoft Excel Objects"
node. Double click the ThisWorkbook to open that code module. In
that code module, paste the following code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "This file was prepared by "
& _
Environ("username") & " on &D at &T"
End Sub

Close the VBA Editor from the File menu. This code will execute
automatically when you print the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
Chip,

Thanks for the info, but copying and pasting that didn't
work..as I didn't
think it would. I don't have any VBA background and I'm
presuming that it is
VBA.

Any other ideas or how can I make this work with my little
programming
knowledge?

Thanks again!

"Chip Pearson" wrote:

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was prepared
by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't figure
it
out.

I want "This file was prepared by 'username' on &[Date} at
&[Time].". But I
can't get the username in there. I've tried everything I
can
think of from
system variables to system variables with an & and things
that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.






  #7  
Old March 30th, 2005, 09:41 PM
Brian Allen - McKEOWN INC.
external usenet poster
 
Posts: n/a
Default

Chip, this worked, but I had to make one change. I had to take the
underscore out. I am using Office 2003, so that may be the difference. Now
to see if it works on an Office XP install as is or if XP wants that
underscore.

Thanks again!

"Chip Pearson" wrote:

Press ALT+F11 to open the VBA Editor, the press CTRL+R to view
the Project Explorer. This will display a tree view window on the
left side of the VBA screen. Find your workbook in the tree
view, expand that node, and expand the "Microsoft Excel Objects"
node. Double click the ThisWorkbook to open that code module. In
that code module, paste the following code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "This file was prepared by "
& _
Environ("username") & " on &D at &T"
End Sub

Close the VBA Editor from the File menu. This code will execute
automatically when you print the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
Chip,

Thanks for the info, but copying and pasting that didn't
work..as I didn't
think it would. I don't have any VBA background and I'm
presuming that it is
VBA.

Any other ideas or how can I make this work with my little
programming
knowledge?

Thanks again!

"Chip Pearson" wrote:

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was prepared
by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't figure
it
out.

I want "This file was prepared by 'username' on &[Date} at
&[Time].". But I
can't get the username in there. I've tried everything I
can
think of from
system variables to system variables with an & and things
that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.






  #8  
Old March 30th, 2005, 09:49 PM
Chip Pearson
external usenet poster
 
Posts: n/a
Default

The _ character (actually a space followed by a _ ) is a line
continuation character. It lets you write one logical line of VBA
code on more than one line in the editor. The code I posted got
line wrapped when posting. If you put the entire
ActiveSheet.CenterHeader = .... line on one line in the editor,
the _ character is not to be used.

It makes no difference what version of Excel you are using.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Brian Allen - McKEOWN INC."
wrote in message
...
Chip, this worked, but I had to make one change. I had to take
the
underscore out. I am using Office 2003, so that may be the
difference. Now
to see if it works on an Office XP install as is or if XP wants
that
underscore.

Thanks again!

"Chip Pearson" wrote:

Press ALT+F11 to open the VBA Editor, the press CTRL+R to view
the Project Explorer. This will display a tree view window on
the
left side of the VBA screen. Find your workbook in the tree
view, expand that node, and expand the "Microsoft Excel
Objects"
node. Double click the ThisWorkbook to open that code module.
In
that code module, paste the following code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "This file was prepared
by "
& _
Environ("username") & " on &D at &T"
End Sub

Close the VBA Editor from the File menu. This code will
execute
automatically when you print the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
Chip,

Thanks for the info, but copying and pasting that didn't
work..as I didn't
think it would. I don't have any VBA background and I'm
presuming that it is
VBA.

Any other ideas or how can I make this work with my little
programming
knowledge?

Thanks again!

"Chip Pearson" wrote:

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was
prepared
by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't
figure
it
out.

I want "This file was prepared by 'username' on &[Date}
at
&[Time].". But I
can't get the username in there. I've tried everything I
can
think of from
system variables to system variables with an & and things
that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.








  #9  
Old March 30th, 2005, 09:57 PM
Brian Allen - McKEOWN INC.
external usenet poster
 
Posts: n/a
Default

Ok, thanks for the explanation. It worked when I removed it, so I had no
problem. And it works in 2000 and Xp as well.

Thanks again!

"Chip Pearson" wrote:

The _ character (actually a space followed by a _ ) is a line
continuation character. It lets you write one logical line of VBA
code on more than one line in the editor. The code I posted got
line wrapped when posting. If you put the entire
ActiveSheet.CenterHeader = .... line on one line in the editor,
the _ character is not to be used.

It makes no difference what version of Excel you are using.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Brian Allen - McKEOWN INC."
wrote in message
...
Chip, this worked, but I had to make one change. I had to take
the
underscore out. I am using Office 2003, so that may be the
difference. Now
to see if it works on an Office XP install as is or if XP wants
that
underscore.

Thanks again!

"Chip Pearson" wrote:

Press ALT+F11 to open the VBA Editor, the press CTRL+R to view
the Project Explorer. This will display a tree view window on
the
left side of the VBA screen. Find your workbook in the tree
view, expand that node, and expand the "Microsoft Excel
Objects"
node. Double click the ThisWorkbook to open that code module.
In
that code module, paste the following code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "This file was prepared
by "
& _
Environ("username") & " on &D at &T"
End Sub

Close the VBA Editor from the File menu. This code will
execute
automatically when you print the workbook.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
Chip,

Thanks for the info, but copying and pasting that didn't
work..as I didn't
think it would. I don't have any VBA background and I'm
presuming that it is
VBA.

Any other ideas or how can I make this work with my little
programming
knowledge?

Thanks again!

"Chip Pearson" wrote:

Brian,

Try something like

ActiveSheet.PageSetup.CenterFooter = "This file was
prepared
by "
& _
Environ("username") & " on &D at &T"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Brian Allen - McKEOWN INC." Brian Allen - McKEOWN
wrote in message
...
I'm trying to put the user name in a footer and can't
figure
it
out.

I want "This file was prepared by 'username' on &[Date}
at
&[Time].". But I
can't get the username in there. I've tried everything I
can
think of from
system variables to system variables with an & and things
that
just shouldn't
work (and didn't).

Any help would be greatly appreciated.









 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
More..Multi User with 1 e-mail account on same PC Dkso General Discussion 0 February 2nd, 2005 09:12 PM
Can I copy the contents of User Field 1 to User Field 4? Robert Judge Contacts 1 January 13th, 2005 02:39 PM
Putting code in a subform? Maury Markowitz General Discussion 14 October 25th, 2004 11:32 AM
Columns and layout problems Phil Setting Up & Running Reports 4 August 18th, 2004 01:34 PM


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


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