覆盖文件(如果已存在)

时间:2019-04-11 08:36:23

标签: excel vba pdf

需要覆盖一个文件(如果已经存在)。在下面的代码行中,使用Adobe api将pdf转换为excel。但是,如果文件已经存在于某个位置(无聊命令),则需要覆盖该文件

Dim objAcroApp      As Acrobat.AcroApp
Dim objAcroAVDoc    As Acrobat.AcroAVDoc
Dim objAcroPDDoc    As Acrobat.AcroPDDoc
Dim objJSO          As Object
Dim boResult        As Boolean
Dim ExportFormat    As String
Dim NewFilePath     As String
'Initialize Acrobat by creating App object.
Set objAcroApp = CreateObject("AcroExch.App")

'Set AVDoc object.
Set objAcroAVDoc = CreateObject("AcroExch.AVDoc")
'Set the PDDoc object.
Set objAcroPDDoc = objAcroAVDoc.GetPDDoc

'Set the JS Object - Java Script Object.
Set objJSO = objAcroPDDoc.GetJSObject
   'some code to define newfilepath format function; confidential so not 
    sharing
    'Save PDF file to the new format.
    boResult = objJSO.SaveAs(NewFilePath, ExportFormat)
    'need boResult to overwrite if file already exists.

0 个答案:

没有答案