Glaswegian
Well-known Member
- Joined
- Oct 14, 2003
- Messages
- 1,487
I have the following code that adds an NT Users loggon name to the right footer when printing. The printed name is appearing as font size 10 - which is the default size for all my worksheets. Other footer details are set at font size 8, but when I try to add the code to change the loggon name to 8 I get an 'Object required' error message and the line ".RightFooter.FontSize = 8" highlighted. Not quite sure what I'm doing wrong here - can anyone help?
Many thanks.
Code:
Sub add_username_to_footer()
'this adds the username from the NT loggon to the footer of a print
'this routine is called each time user clicks on print checkbox and print button
Dim strBuf As String, lngUser As Long, strUn As String
strBuf = Space$(255) '//Clear buffer
lngUser = WNetGetUser("", strBuf, 255)
If lngUser = NO_ERROR Then
strUn = Left(strBuf, InStr(strBuf, vbNullChar) - 1)
Else
End If
With ActiveSheet.PageSetup
.RightFooter = ""
.RightFooter = "User: " & strUn
.RightFooter.FontSize = 8
End With
End Sub
Many thanks.