小编use*_*479的帖子

检查某个pdf文件是否已打开并关闭

我使用此代码从word文档导出pdf文件.

在导出之前,我需要首先检查一个具有相同名称的文件是否已经打开,如果是这样,则将其导出.

我尝试了很多东西,但没有运气.

Dim adbApp As Acrobat.AcroApp
Dim adbDoc As Acrobat.AcroAVDoc
Dim adbPageView As Acrobat.AcroAVPageView

Set adbApp = CreateObject("AcroExch.App")
Set adbDoc = CreateObject("AcroExch.AVDoc")

If adbDoc.Open("C:\Current Letter Preview.pdf", "") = True Then '==> If the file is not open, this line opens it
    adbDoc.Close (1) '==> Then close it

    If adbDoc Is Nothing Then '==> Doesn't understand that I want to check if any pdf files are open
        adbApp.Exit
    End If

    Set adbApp = Nothing
End If

Dim wordApp As Word.Application …
Run Code Online (Sandbox Code Playgroud)

pdf excel vba excel-vba

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

excel ×1

excel-vba ×1

pdf ×1

vba ×1