我有个文件夹,里面全部为word文档,想全部转化为pdf,代码如下,报错是什么原因?
Dim dlg As New FolderBrowserDialog
If dlg.ShowDialog = DialogResult.Ok Then
For Each File As String In FileSys.GetFiles(dlg.SelectedPath)
Dim rs As String = File.SubString(0,File.Length-4)
Dim tg As String = rs & ".pdf"
Dim app As New MSWord.Application
try
Dim doc = app.Documents.Open(File)
doc.ExportAsFixedFormat(tg, MSWord.WdExportFormat.wdExportFormatPDF)
doc.saved = True
app.Quit
catch ex As exception
msgbox(ex.message)
app.Quit
End try
Next
End If