Consulting

Results 1 to 5 of 5

Thread: Solved: footer code error

  1. #1
    VBAX Regular
    Joined
    Sep 2004
    Posts
    61
    Location

    Solved: footer code error

    Hi forum,

    I am trying to get automated data into a footer and am using the following code:

    [vba]With ActiveSheet.PageSetup
    .RightFooter = "Date Page Printed:" & [Date] & vbLf & _
    "Time Page Printed:" & [Time] & vbLf & _
    "Printed by:" & Application.UserName

    End With[/vba]

    However something is wrong as it says I have a runtime error '13' .. type mismatch

    Also how do I change the font to size 8.

    Any help is greatly appreciated.

    Koala

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    With ActiveSheet.PageSetup
    .RightFooter = "&8Date Page Printed:" & Date & vbLf & _
    "Time Page Printed:" & Time & vbLf & _
    "Printed by:" & Application.UserName

    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Sep 2004
    Posts
    61
    Location
    Thanks xld,

    That works great, (those damn square brackets), however it takes up lots of space so I changed to

    [VBA]With ActiveSheet.PageSetup
    .RightFooter = "&8 Printed by: " & Application.UserName & " on " & Date & " at " & Time

    End With[/VBA]

    to get one line which I think looks neater on the printout

    Can you also point me how to change the date format to "ddd, dd mmm yyyy", so I can compare that as well.

    Thanks again, your help is appreciated

    Koala

  4. #4
    VBAX Regular
    Joined
    Sep 2004
    Posts
    61
    Location
    Solved it

    [VBA]With ActiveSheet.PageSetup
    .RightFooter = "&8 Printed by: " & Application.UserName & " on " & Format(Date, "ddd, dd mmm yyyy") & " at " & Time

    End With[/VBA]

    Thanks again for your help xld

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    @XLD
    Nice :-) I wouldn't have thought to ditch the formatting code &D right away at least.

    @Koala:
    Try:
    Format(Date, "ddd, dd mmm yyyy")

    A good day to all,

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •