Excel宏另存为PDF

Excel宏另存为PDF,excel,vba,pdf,Excel,Vba,Pdf,我有一个宏,它应用一些过滤器,然后将某些列导出为PDF文件,目前该宏将PDF保存在与Excel文件相同的文件夹中,但我想让它问我想将文件保存在哪里,这可能吗 非常感谢您的帮助!:) 是的,这是可能的。将此添加到您的代码中。它将要求用户选择保存文件的位置 Sub download_location() Dim user As String Dim fldr As FileDialog Dim sItem As String Dim getfolder As Stri

我有一个宏,它应用一些过滤器,然后将某些列导出为PDF文件,目前该宏将PDF保存在与Excel文件相同的文件夹中,但我想让它问我想将文件保存在哪里,这可能吗

非常感谢您的帮助!:)


是的,这是可能的。将此添加到您的代码中。它将要求用户选择保存文件的位置

Sub download_location()
    Dim user As String
    Dim fldr As FileDialog
    Dim sItem As String
    Dim getfolder As String
    user = Application.UserName
    
    Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
    With fldr
        .Title = "Select a Folder"
        .AllowMultiSelect = False
        .InitialFileName = Application.DefaultFilePath
        If .Show <> -1 Then GoTo NextCode
        sItem = .SelectedItems(1)
    End With
NextCode:
    getfolder = sItem
    Set fldr = Nothing


'do something here

End Sub
子下载位置()
将用户设置为字符串
Dim fldr As FILE对话框
以字符串形式显示
将文件夹设置为字符串
user=Application.UserName
设置fldr=Application.FileDialog(msoFileDialogFolderPicker)
与fldr
.Title=“选择一个文件夹”
.AllowMultiSelect=False
.InitialFileName=Application.DefaultFilePath
如果.Show-1,则转到下一个代码
sItem=.SelectedItems(1)
以
下一个代码:
getfolder=sItem
设置fldr=无
“在这里做点什么
端接头
Sub download_location()
    Dim user As String
    Dim fldr As FileDialog
    Dim sItem As String
    Dim getfolder As String
    user = Application.UserName
    
    Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
    With fldr
        .Title = "Select a Folder"
        .AllowMultiSelect = False
        .InitialFileName = Application.DefaultFilePath
        If .Show <> -1 Then GoTo NextCode
        sItem = .SelectedItems(1)
    End With
NextCode:
    getfolder = sItem
    Set fldr = Nothing


'do something here

End Sub