将当前日期添加到Excel宏

时间:2016-04-01 17:30:16

标签: excel vba

有人可以帮我编辑这个Excel宏吗?在右侧页脚,我希望当前日期以mm / dd / yy格式显示。

mut.lock_shared()

1 个答案:

答案 0 :(得分:0)

试试这个 -

Sub Document_Standards()
'
' Document_Standards Macro
'

'
    ActiveWindow.View = xlPageLayoutView
    Selection.Font.Size = 12
    Selection.Font.Size = 14
    Selection.Font.Bold = True
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = "&""-,Bold""&14&F"
        .RightHeader = ""
        .LeftFooter = "Created by Chris"
        .CenterFooter = "CONFIDENTIAL"
        .RightFooter = "Printed on " & Date()
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.75)
        .BottomMargin = Application.InchesToPoints(0.75)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    Application.PrintCommunication = True
    ActiveSheet.Shapes.Range(Array("Picture 1")).Select
End Sub