|
-
Dec 28th, 2022, 03:40 PM
#41
New Member
Re: menuItemExecute
Great code here ^^
This code in some cases will open a Modal menu and Excel (for example) will keep waiting for the Adobe Menu to be closed before continuing. Changing to PostMessage opens the menu and continues the code.
You could add:
Code:
Private Declare PtrSafe Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
and change to:
Code:
L = PostMessage(Hwnd, WM_COMMAND, M.wID, ByVal 0)
(thanks)
-
Dec 28th, 2022, 03:42 PM
#42
New Member
Re: menuItemExecute
 Originally Posted by Fazi
vijy,
try this example shows how to execute notepad's Help>About Notepad menu item. Before run this code,keep open your note pad.
Code:
Option Explicit
Private Const WM_COMMAND = &H111
Private Const MIIM_TYPE = &H10
Private Const MIIM_ID = 2
Private Type MENUITEMINFO
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As String
cch As Long
End Type
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetMenu Lib "user32" (ByVal Hwnd As Long) As Long
Private Declare Function GetMenuItemInfo Lib "user32" Alias "GetMenuItemInfoA" _
(ByVal hMenu As Long, ByVal un As Long, ByVal b As Long, lpMenuItemInfo As MENUITEMINFO) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Code:
Sub MenuClick(Hwnd As Long, Menu As Long, Item As Long)
Dim hMenu As Long, hSubMenu As Long, L As Long
Dim M As MENUITEMINFO
If Hwnd Then
hMenu = GetMenu(Hwnd)
If hMenu Then
hSubMenu = GetSubMenu(hMenu, Menu)
If hSubMenu Then
M.fMask = MIIM_TYPE Or MIIM_ID
M.dwTypeData = Space$(128)
M.cbSize = Len(M)
M.cch = 128
L = GetMenuItemInfo(hSubMenu, Item, True, M)
L = SendMessage(Hwnd, WM_COMMAND, M.wID, ByVal 0)
End If
End If
End If
End Sub
Code:
' Example - Open Notepad's About Dialog.
Private Sub Command1_Click()
Dim Lng As Long
Lng = FindWindow(vbNullString, "Untitled - Notepad")
MenuClick Lng, 4, 2 ' 0 based, menu seperators count as an item.
'4 mean, the 5th menu in note pad. 2 mean the 3rd item in the 5th menu. as sad, starts at 0 based.
End Sub
How this will give you the idea.
Great code here ^^
This code in some cases will open a Modal menu and Excel (for example) will keep waiting for the Adobe Menu to be closed before continuing. Changing to PostMessage opens the menu and continues the code.
You could add:
Code:
Private Declare PtrSafe Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
and change to:
Code:
L = PostMessage(Hwnd, WM_COMMAND, M.wID, ByVal 0)
(thanks, 15 years later)
Last edited by howdykeith; Dec 28th, 2022 at 03:49 PM.
-
Dec 28th, 2022, 03:57 PM
#43
New Member
Re: [RESOLVED] menuItemExecute
 Originally Posted by vijy
Am trying to execute a menu item " Documents " in the Adobe Profeesional 7.0
Code:
Dim Ok as boolean
ok = AcrobatApp.MenuItemExecute("DigSig:ToolsDiff")
This not working..
This ok return false only at all time..
Can anybody say how to execute this menu??
Another possible solution:
Code:
Sub MenuItemExecuteLateBind()
Dim AcroApp As Object
Dim OpenThisDoc As Object
Set OpenThisDoc = CreateObject("AcroExch.PDDoc")
Set AcroApp = CreateObject("AcroExch.App")
'AcroApp.Show
OpenThisDoc.Open "C:\Temp\MyAdobeFile.pdf"
'AcroApp.MenuItemExecute ("Open")
AcroApp.MenuItemExecute ("DigSig:ToolsDiff")
End Sub
-
Dec 28th, 2022, 04:00 PM
#44
New Member
Re: menuItemExecute
 Originally Posted by howdykeith
Great code here ^^
This code in some cases will open a Modal menu and Excel (for example) will keep waiting for the Adobe Menu to be closed before continuing. Changing to PostMessage opens the menu and continues the code.
You could add:
Code:
Private Declare PtrSafe Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal Hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
and change to:
Code:
L = PostMessage(Hwnd, WM_COMMAND, M.wID, ByVal 0)
(thanks)
^^ Please delete, thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|