Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Complicated If Then / V Lookup / Match Statement... | Excel Worksheet Functions | |||
Conform a total to a list of results? | Excel Discussion (Misc queries) | |||
Macro for changing text to Proper Case | Excel Worksheet Functions | |||
Find the cell value in excel by using vb code | Excel Discussion (Misc queries) | |||
Formatting footer in VBA code | Excel Discussion (Misc queries) |