首页 > 解决方案 > 如果文件已存在,则覆盖该文件

问题描述

如果文件已经存在,需要覆盖。在以下代码行中使用 Adob​​e api 将 pdf 转换为 excel。但是,如果文件已存在于某个位置(boresult 命令),则需要覆盖该文件

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.

标签: excelvbapdf

解决方案


推荐阅读