从excel生成PDF并在XChange Viewer中打开

时间:2018-05-08 00:37:04

标签: excel vba excel-vba

这是我的代码:

Sub Export()
Dim wsA As Worksheet
Dim wsB As Workbook
Dim strPath As String
Dim strName As String
Dim strPathFile As String
Dim OpenFile

Set wbA = ActiveWorkbook
Set wsA = ActiveWorksheet

strPath = CreateObject("WScript.Shell").specialfolders("Desktop")
If strPath = "" Then
strPath = wbA.path
End If
strPath = strPath & "\"

strName = "My Document"

strFile = strName & ".pdf"
strPathFile = strPath & strFile

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

appPath = "C:\Program Files\TrackerSoftware\PDFViewer\PDFXCView.exe"
OpenFile = Shell(appPath&" "& strPathFile, vbNormalFocus)
End Sub

如果我没有命令它保存在桌面上,我可以在xchange viewer上打开我生成的PDF。现在它只打开没有我的文档的Xchange Viewer :(

0 个答案:

没有答案