Link in Zwischenablage kopieren
Kopiert
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
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
Link in Zwischenablage kopieren
Kopiert
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?
Link in Zwischenablage kopieren
Kopiert
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?
Link in Zwischenablage kopieren
Kopiert
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
Link in Zwischenablage kopieren
Kopiert
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.
Link in Zwischenablage kopieren
Kopiert
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