• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Acrobat instance still running after closing using VBA

New Here ,
Jul 31, 2023 Jul 31, 2023

Copy link to clipboard

Copied

I have exhaustively searched for an answer, with limited success.

 

I open a document from Excel using:

 

Set AcroApp = CreateObject("AcroExch.App")
Set AvDoc = CreateObject("AcroExch.AVDoc")

'Open temporary file
AvDoc.Open "C:\Users\saylork\Documents\Waste Pickup Temp.pdf", ""
Set AcroForm = CreateObject("AFormAut.App")
Set Fields = AcroForm.Fields

 

After extracting data, I attempt to close it using:

Set Fields = Nothing
Set AcroForm = Nothing
AvDoc.Close True
AcroApp.CloseAllDocs
AcroApp.Exit
Set AcroApp = Nothing
Set AvDoc = Nothing

 

I've tried various ordering of the above just in case that made a difference, nope.

 

Also tried (APIs at top of code):

 

Sub CloseAdobeReader()
Dim strClassName As String
Dim hwnd As Long

strClassName = "AcrobatSDIWindow"
hwnd = FindWindow(strClassName, vbNullString)
If hwnd Then
SendMessage hwnd, WM_CLOSE, 0, ByVal 0&
Else
MsgBox "Adobe is not running!"
End If
End Sub

 

This will force a shut down. However, I'm opening and closing in a loop. It works the first time through (imports and closes), misses the second (no import, returns message) and works the third.

 

Is there a reliable way to close it?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

426

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 18, 2023 Aug 18, 2023

HI,

There is not a reliable way to close in this workflow, I have not found a good way it is always something like what you have, although I tend to add a delay between the end of the run and the start of the next ( it does delay things) but that way you make sure Acrobat can shutdown and restart before you start processing.

 

 

Votes

Translate

Translate
Community Expert ,
Aug 18, 2023 Aug 18, 2023

Copy link to clipboard

Copied

LATEST

HI,

There is not a reliable way to close in this workflow, I have not found a good way it is always something like what you have, although I tend to add a delay between the end of the run and the start of the next ( it does delay things) but that way you make sure Acrobat can shutdown and restart before you start processing.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines