如何直接造成word文件到电脑桌面上?下面代码如何调整?
Dim app As New MSWord.Application
Try
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter = "Word文件|*.doc;*.docx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
MessageBox.Show("你选择的是:" & dlg.FileName,"提示") '提示用户选择的文件
Dim doc = app.Documents.Open(dlg.FileName)
Dim str As String = FileSys.GetName(dlg.FileName)
Dim filt As String = str.SubString(0,str.LastIndexOf("."))
Dim pth As String = SpecialFolder.DesktopDirectory & filt & ".pdf"
msgbox(pth)
app.Documents(dlg.FileName).ExportAsFixedFormat(pth, MSWord.WdExportFormat.wdExportFormatPDF)
app.Quit
End If
Catch ex As Exception
msgbox(ex.message)
app.Quit
End Try