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

GetActiveDoc does not find a minimized window

Community Beginner ,
May 08, 2019 May 08, 2019

Copy link to clipboard

Copied

Running Windows 7, Acrobat Pro DC, Excel vba

I'm finding that the following code does not find the active document if the active document is minimized.

Otherwise the code works fine.

Is there a better method? I would like my code to find a minimized window as an active document.

I haven't found any reference to this in Adobe Acrobat SDK documentation.

Thanks

Dim pdApp As acrobat.CAcroApp

Dim pdDoc As acrobat.CAcroPDDoc

Dim pdFile As acrobat.CAcroAVDoc

Set pdApp = CreateObject("AcroExch.App")
Set pdDoc = CreateObject("AcroExch.PDDoc")
Set pdFile = pdApp.GetActiveDoc

If (pdFile Is Nothing) Then
MsgBox "nothing"
End If

TOPICS
Acrobat SDK and JavaScript

Views

1.0K

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 , May 09, 2019 May 09, 2019

Hi,

Could you not use GetAVDoc ( long nIndex), and pass in the index as you know how many documents you have this should always be able to get the document you want.

Regards

Malcolm

Votes

Translate

Translate
LEGEND ,
May 08, 2019 May 08, 2019

Copy link to clipboard

Copied

If it’s mimimized it isn’t active. Often there is no active doc despite having open docs. You can enumerate all open docs and decide what to do in this case but take care - how will you pick one?

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
Community Beginner ,
May 09, 2019 May 09, 2019

Copy link to clipboard

Copied

Well earlier in the code I do enumerate open docs and if more than 1 or 0 the user is alerted and then exit sub.

So if there is only one doc open and its minimized, but I do not know the file name can I activate that doc?

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
Community Expert ,
May 09, 2019 May 09, 2019

Copy link to clipboard

Copied

Hi,

Could you not use GetAVDoc ( long nIndex), and pass in the index as you know how many documents you have this should always be able to get the document you want.

Regards

Malcolm

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
LEGEND ,
May 09, 2019 May 09, 2019

Copy link to clipboard

Copied

You can't necessarily activate it. For example, if the user selects the Tools tab their document might become inactive, and you cannot change the tabs displayed. You can try activating it but be prepared for failure.

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
Community Beginner ,
May 09, 2019 May 09, 2019

Copy link to clipboard

Copied

LATEST

True if the user has the tools tab selected, the routine will not find it.

However, the case of minimizing is a much more likely case for the user to encounter.

For this application using the GetAVDoc method does work although I need to fine tune things a bit.

        Dim pdApp As acrobat.CAcroApp

        Dim pdDoc As acrobat.CAcroPDDoc

        Dim pdFile As acrobat.CAcroAVDoc

        Dim pdAVdoc As acrobat.CAcroAVDoc

Set pdApp = CreateObject("AcroExch.App")
Set pdDoc = CreateObject("AcroExch.PDDoc")
Set pdAVdoc = pdApp.GetAVDoc(0)

If pdAVdoc Is Nothing Then
MsgBox "not getting AVDoc"

Exit Sub
End If

pdAVdoc.BringToFront


Set pdFile = pdApp.GetActiveDoc

If (pdFile Is Nothing) Then
MsgBox "The survey Home or Tools tab cannot be selected."

Exit Sub
End If

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