Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel打印到PDF文件夹_Excel_Pdf_Directory - Fatal编程技术网

Excel打印到PDF文件夹

Excel打印到PDF文件夹,excel,pdf,directory,Excel,Pdf,Directory,在这件事上有点疯狂。不知道为什么这个代码不起作用。我的PDF文件正在保存,但它将保存到“我的文档”文件夹,而不是定向文件。它需要进入这个文件来保存文档,我还有另一个代码来发送电子邮件,并从这个目录附加这个文件 Sub PrintPOPDFtoFolder() ChDir "R:\Procurement\Purchase Orders" & "\" 'files directory fileSaveName = ActiveSheet.Range("Q7") 'Name th

在这件事上有点疯狂。不知道为什么这个代码不起作用。我的PDF文件正在保存,但它将保存到“我的文档”文件夹,而不是定向文件。它需要进入这个文件来保存文档,我还有另一个代码来发送电子邮件,并从这个目录附加这个文件

Sub PrintPOPDFtoFolder()

   ChDir "R:\Procurement\Purchase Orders" & "\" 'files directory
   fileSaveName = ActiveSheet.Range("Q7") 'Name the PDF file

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
       fileSaveName _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False


    MsgBox "File Saved " & " " & fileSaveName

End Sub
在ExportAsFixedFormat调用中使用完整文件路径,而不是依赖ChDir:

fileSaveName = "R:\Procurement\Purchase Orders\" & ActiveSheet.Range("Q7").Value