【问题标题】:Get time in filename save in word macro获取文件名中的时间保存在 Word 宏中
【发布时间】:2020-03-31 05:24:58
【问题描述】:

我有一个 word 宏,它将文档保存为 pdf 并通过电子邮件发送。唯一的问题是它会在网络驱动器上覆盖自己。我不知道如何使用下面的代码将秒数转换为文件名。

感谢您的帮助!

dte = Date
savedName = "Night Orders - " & Format(dte, "yyyy-mm-dd")

Response = MsgBox("Save and email the current document?", vbOKCancel, "Are you sure?")
    If Response = vbOK Then

        savePath = saveDir & saveName & ".pdf"
        ActiveDocument.ExportAsFixedFormat OutputFileName:=savePath, _
            ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, _
            OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportAllDocument, _
            From:=1, To:=1, Item:=wdExportDocumentContent, IncludeDocProps:=True, _
            KeepIRM:=True, CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
            BitmapMissingFonts:=True, UseISO19005_1:=False

【问题讨论】:

  • 你看过VBA函数Time吗?

标签: vba ms-word


【解决方案1】:

试试:

savedName = "Night Orders - " & Format(Now, "YYYY-MM-DD-hh-mm-ss")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-07
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多