سؤال

I'm embedding a PDF in an Excel file and then using VBA to open it as follows:

Dim objMan As OLEObject
Set objMan = ThisWorkbook.Worksheets("Public").OLEObjects.Item("Doc")
objMan.Activate

The problem I have is that it opens it in the background and the used then needs to manually open it from the taskbar to view it. While looking for some method for an OLEObject to set focus or something, I came across the Verb Method for OLEObjects.

MSDN states that this method sends a command to the OLEObject and the available commands "are determined by the object's source application".

My question is: how do I determine what verbs are available for an Adobe Acrobat Document?

هل كانت مفيدة؟

المحلول

You should not need to use the .Activate method on the OLEObject, unless there is some specific reason that you need it to be Active within the workbook/worksheet. Most of the time, there is no reason to do this.

There are only two Verbs available for an embedded PDF OLEObject:

PDF OleObject Verbs

When I do oleObj.Verb xlVerbOpen this opens the PDF with focus on my machine (Win 7/Excel 2010).

When I do oleObj.Verb xlVerbPrimary this activates the PDF but does not give it focus.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top