Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How do I code authorship into a footer?

I would like the author's initials to appear in a footer. How do I add a
code so that when the user changes, it automatically changes the footer?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 284
Default How do I code authorship into a footer?

Here is one option that might work for you

__________________________

Private Sub Workbook_Open()

Set objWord = CreateObject("Word.Application")
strInitials = objWord.UserInitials
objWord.Quit
Set objWord = Nothing

For Each objWksheet In ThisWorkbook.Worksheets
objWksheet.PageSetup.LeftFooter = strInitials
Next objWksheet

End Sub

__________________________

Steve

"mkblue" wrote in message
...
I would like the author's initials to appear in a footer. How do I add a
code so that when the user changes, it automatically changes the footer?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How do I code authorship into a footer?

The author and user could be two separate entities.

The author is the person whose name appears on FilePropertiesSummary.

The user would be whoever has the workbook open.

Either or both would have to be done through code.

For the author...................

'=DOCPROPS("author")
'or
'=DOCPROPS("last save time")
'or
'DOCPROPS("creation date")

Function DocProps(prop As String)
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function

Then let this BeforePrint code run which will give both author and username if
different.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Application.UserName < DocProps("author") Then
ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName & " " & _
ActiveSheet.Name & " User " & Application.UserName & " " & Date _
& " Author " & DocProps("author")
Else: ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName & " " _
& ActiveSheet.Name & " User " & Application.UserName & " " & Date
End If
End Sub

Edit out the properties you don't want included.

I don't know how to get the author's initials without some more work


Gord Dibben MS Excel MVP


On Sat, 9 Sep 2006 12:58:01 -0700, mkblue
wrote:

I would like the author's initials to appear in a footer. How do I add a
code so that when the user changes, it automatically changes the footer?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 284
Default How do I code authorship into a footer?

Gord,

Something like:

Sub UserInitials()
Dim strInitials As String

arrFullName = Split(Application.UserName)
For N = 0 To UBound(arrFullName)
strInitials = strInitials & Left(arrFullName(N), 1)
Next N

MsgBox strInitials

End Sub

could be integrated with your code to return initials whether looking at the
author or the current user. I just assumed the OP wanted the current user
even though they did use the term author as well. I looked at an expanded
version of what I have above but in my case, it returns SY because I set up
my system using just first and last name but when asked for initials I
generally include my middle initial, SJY. The Word object can quickly
produce the user's initials as they prefer them although I suspect it isn't
the most efficient way to do things from Excel.

Steve


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Edit out the properties you don't want included.

I don't know how to get the author's initials without some more work


Gord Dibben MS Excel MVP



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How do I code authorship into a footer?

Thanks for the info Steve.

Not something I would have ever come up with.


Gord

On Sat, 9 Sep 2006 16:32:35 -0700, "Steve Yandl"
wrote:

Gord,

Something like:

Sub UserInitials()
Dim strInitials As String

arrFullName = Split(Application.UserName)
For N = 0 To UBound(arrFullName)
strInitials = strInitials & Left(arrFullName(N), 1)
Next N

MsgBox strInitials

End Sub

could be integrated with your code to return initials whether looking at the
author or the current user. I just assumed the OP wanted the current user
even though they did use the term author as well. I looked at an expanded
version of what I have above but in my case, it returns SY because I set up
my system using just first and last name but when asked for initials I
generally include my middle initial, SJY. The Word object can quickly
produce the user's initials as they prefer them although I suspect it isn't
the most efficient way to do things from Excel.

Steve


"Gord Dibben" <gorddibbATshawDOTca wrote in message
.. .
Edit out the properties you don't want included.

I don't know how to get the author's initials without some more work


Gord Dibben MS Excel MVP





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default How do I code authorship into a footer?

I have roughly the same question, although the previous replies aren't
helping much because I don't know where exactly to PUT the code. We have a
shared workbook that at least 3 of our staff are using at once. It has a
form that we print and put in a binder. I'd like the footers to show the
user name, if possible. Any help?

"mkblue" wrote:

I would like the author's initials to appear in a footer. How do I add a
code so that when the user changes, it automatically changes the footer?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How do I code authorship into a footer?

Right-click on the Excel logo left of "File" on menu bar or at left side of
window Title bar if not maximized.

Select "View Code"

Paste this into the Thisworkbook module that opens.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName & " " & _
ActiveSheet.Name & " " & Environ("UserName") & " " & Date
End Sub

Edit out any bits you don't want. Stripped down to just Username would be

Private Sub Workbook_BeforePrint(Cancel As Boolean)
ActiveSheet.PageSetup.RightFooter = Environ("UserName")
End Sub

Note: you could change to LeftFooter or CenterFooter

Alt + q to go back to your Excel Window.

Save the workbook.


Gord Dibben MS Excel MVP

On Wed, 17 Jan 2007 14:40:00 -0800, IMS Lori
wrote:

I have roughly the same question, although the previous replies aren't
helping much because I don't know where exactly to PUT the code. We have a
shared workbook that at least 3 of our staff are using at once. It has a
form that we print and put in a binder. I'd like the footers to show the
user name, if possible. Any help?

"mkblue" wrote:

I would like the author's initials to appear in a footer. How do I add a
code so that when the user changes, it automatically changes the footer?


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
Complicated If Then / V Lookup / Match Statement... ryesworld Excel Worksheet Functions 17 December 10th 05 02:09 PM
Conform a total to a list of results? xmaveric Excel Discussion (Misc queries) 1 August 21st 05 07:22 PM
Macro for changing text to Proper Case JPriest Excel Worksheet Functions 3 August 8th 05 09:31 PM
Find the cell value in excel by using vb code Michael Excel Discussion (Misc queries) 5 June 14th 05 01:24 PM
Formatting footer in VBA code Frantic Excel-er Excel Discussion (Misc queries) 2 June 10th 05 04:04 PM


All times are GMT +1. The time now is 06:19 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"