将excel另存为pdf,将文件名另存为变量值

迭戈

我正在尝试将选择保存为pdf,除了我无法保存带有特定名称的文件之外,其他所有方法都可以正常工作,我希望名称为Report Sub和日期和时间...除了我今天尝试放置时,它可以正常工作日期和时间...这是我的代码

Sub guardar_pdf()
'
' Macro7 Macro
'

'
    Range("A1:Q4").Select


    With ActiveSheet.PageSetup

        .Orientation = xlLandscape
        .Zoom = 60
        .PrintGridlines = True
    End With

     Dim fe As String
    fe = now

     With Selection

    .ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "C:\Users\Diego\Dropbox\informes\informe"&fe, Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End With



End Sub
垃圾桶

有几种方法可以解决此问题。

fe = Format(Now, "yyyymmdd_hhmmss")

或忽略它,然后执行此操作

"C:\Users\Diego\Dropbox\informes\informe" & Format(Now, "yyyymmdd_hhmmss")

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章