🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.acrobat.sdk
Article #328

How to Hide Acrobat When Running VBA Code

#328
From: Kevin_Ha
Date: Wed, 04 Mar 2009 14:46
46 lines
2721 bytes
I am using Acrobat 9.

My project adds text to Acrobat fillable fields using VBA written in Access 2003. I take records from my Access database, and populate it into different Acrobat Forms based on the field name in the Acrobat Form. I am able to do this, but there is one problem.

The problem is that as the code runs through populating text in the Acrobat Forms, Acrobat opens up each form, and makes it visible to the user. It populates quick, but it is still visible. I want this to run in the background, or at least be minimized in the windows taskbar. The users should not not know which form the Application is updating. It should be hidden or invisible. That is the goal at least :)

I know which line in the code causes it to Maximize, but if I remove that line, I receive an error about No Document Currently Open in Acrobat Viewer.

Here is the snippet of the code I am using. Any help would be greatly appreciated.

Dim gApp As Acrobat.CAcroApp
    Dim avdoc As Acrobat.CAcroAVDoc
    Dim gPDDoc As Acrobat.CAcroPDDoc
    Const DOC_FOLDER As String = "C:\Trial"
    Dim x As Boolean

Set gApp = CreateObject("AcroExch.App")
    Set gPDDoc = CreateObject("AcroExch.PDDoc")
    Set avdoc = CreateObject("AcroExch.AVDoc")

'Hides Acrobat - So Far So Good
    gApp.Hide

Dim FormApp As AFORMAUTLib.AFormApp
    Dim AcroForm As AFORMAUTLib.Fields
    Dim Field As AFORMAUTLib.Field

'Open PDF that I choose. Acrobat still has not flashed on my screen
    x = avdoc.Open(DOC_FOLDER & "\trial.pdf", "temp")

'Acrobat Now Pops up on my screen. However, I get an error without this line. avdoc.Show works the same as Maximize it seems.
        avdoc.Maximize(1)

'Hides it again, right after it opens. This creates a flash
       gApp.Hide

Set FormApp = CreateObject("AFormAut.App")

'If the Maximize line is not there, this is where I receive error about document viewer
        For Each Field In FormApp.Fields
            If Field.Name = "Sample_FieldName" Then
                Field.Value = TextToUse
            End If
        Next

Please let me know if you can think of a way to keep Acrobat hidden. Thank you.
Technical Details
Message-ID: <59b81c8d.-1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newshub.sdsu.edu!webcrossing

Show Full Headers
Complete Article Headers
X-Google-Thread: 10177e,bbcf2646a4dcbb47,start
X-Google-Attributes: gid10177e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Kevin_Ha@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.google.com!newshub.sdsu.edu!webcrossing
Newsgroups: adobe.acrobat.sdk
Subject: How to Hide Acrobat When Running VBA Code
Message-ID: <59b81c8d.-1@webcrossing.la2eafNXanI>
Date: Wed, 4 Mar 2009 06:46:12 -0800
Lines: 61
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit