【发布时间】:2019-12-26 20:22:58
【问题描述】:
我正在使用 Excel vba 来修改 Word 文档,然后将其另存为 pdf。它运行顺利,它会创建一个 pdf 文件,但不会创建扩展名。所以基本上问题是文件不被识别为pdf(图标不是pdf图标)并且在打开时,它会要求应用程序用来打开文件。在 Windows 资源管理器中,此文件的“扩展名”下有一个空白。
用于转换为pdf的部分代码为:
Dim saved_successfull As Boolean
saved_successfull = False
Dim fenetre_saveas As Object
Set fenetre_saveas = Application.FileDialog(msoFileDialogSaveAs)
With fenetre_saveas 'save as pdf
.InitialFileName = nom_complet
.Title = "Confirmer le répertoire où le pdf sera sauvegardé"
.InitialView = msoFileDialogViewList
.FilterIndex = 25
If .Show <> 0 Then
worddoc.ExportAsFixedFormat _
OutputFileName:=nom_complet, _
ExportFormat:=wdExportFormatPDF, Openafterexport:=False
saved_successfull = True
End If
End With
If saved_successfull = True Then
worddoc.Close savechanges:=False 'fermeture du doc word
WordApp.Quit
MsgBox ("Saved successfull")
Exit Sub
Else
MsgBox ("Couldn't convert in pdf")
End If
Exit Sub
所以基本上没有生成错误消息。我收到消息框(“Saved succesfull”),文件以正确的名称保存在所需的路径中。但是文件的扩展名不存在。
所以它是一个pdf,但它不会被自动识别为一个。如果我使用pdf阅读器打开它,它将被阅读。
任何想法,我错过了什么?
非常感谢您。
【问题讨论】:
标签: excel vba ms-word pdf-generation