将docx转换为pdf后如何找到文件路径

How to find the file path after converting a docx to pdf

我需要在从 docx 转换后获取 PDF 的文件位置

我得到了下面的转换代码,但它没有提供任何关于 PDF 位置的信息

mydoc.ExportAsFixedFormat _
Outputfilename:=Replace(mydoc.FullName, ".docx", ".pdf"), _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=True, 
OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, Item:=wdExportDocumentContent

我希望在转换后,我可以将 PDF 位置记录到单元格中。

谢谢

myDoc.FullName 包含文件的路径,因此当您将其设置为导出的输出文件名并将扩展名从 .docx 替换为 .pdf 时,您就设置了PDF 的路径与原始文档位于同一文件夹。

使用此处的值设置带有 PDF 文件路径的单元格。

ThisWorkbook.Worksheets("sheetname").Range("A1").Value = Replace(myDoc.FullName, ".docx", ".pdf")

这会将工作表 "sheetname" 上的单元格 A1 设置为 pdf 的文件路径。