自动将PDF文件保存在新文件夹中 [英] Save PDF file automatically in new folder

查看:91
本文介绍了自动将PDF文件保存在新文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下宏,可以在Excel文件所在的文件夹中创建一个文件夹:

I have the following macro to create a folder within the folder where the Excel file is:

Sub Folder_Test()
    If Dir(ThisWorkbook.Path & "\" & "Folder_01", vbDirectory) = "Folder_01" Then
        MsgBox "Folder already exists!"
    Else
        MkDir Application.ThisWorkbook.Path & "\" & "Folder_01"
    End If
End Sub

并且我具有以下宏来创建PDF文件:

And I have the following macro to create a PDF file:

Sub Button_PDF_200()
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        ThisWorkbook.Path & "\" & "test.pdf", Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub

现在我希望在第二个宏中创建的PDF文件将保存在第一个宏中创建的文件夹中.

Now I want that the PDF file which is created in the second macro will be saved in the folder which is created in the first macro.

您知道我该怎么做吗?

推荐答案

也许就是这样?

Sub Button_PDF_200()
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        ThisWorkbook.Path & "\" & "Folder_01" & "\" & "test.pdf", Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub


这正在更改


That is changing the Filename argument within the sub Button_PDF_200 from

ThisWorkbook.Path & "\" & "test.pdf"

ThisWorkbook.Path & "\" & "Folder_01" & "\" & "test.pdf"

这篇关于自动将PDF文件保存在新文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆