Page 1 of 2 12 LastLast
Results 1 to 40 of 44

Thread: [RESOLVED] menuItemExecute

  1. #1

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Resolved [RESOLVED] menuItemExecute

    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??
    Visual Studio.net 2010
    If this post is useful, rate it


  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    Would you like to use SendKeys?

  3. #3

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Without using sendKeys is it possible to fire this menu?
    Last edited by vijy; Oct 19th, 2007 at 11:47 PM.
    Visual Studio.net 2010
    If this post is useful, rate it


  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    only other way i know is SendMessage / PostMessae

  5. #5

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Sorry i don know Send.../post messag..
    If any solution in .net too?? U can share..
    Could u say why menuItemExecute not working..??
    Visual Studio.net 2010
    If this post is useful, rate it


  6. #6

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    U Pls share how to use post/send message in this application???
    Visual Studio.net 2010
    If this post is useful, rate it


  7. #7
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    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.

  8. #8

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Thanks Fazi..
    I studied this code..Any reference we have to include????

    Let me try this in Adobe also...
    Visual Studio.net 2010
    If this post is useful, rate it


  9. #9
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    no referrences.
    only you need the handle of the window where that menus are hanging.

  10. #10

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Thank u...
    Let me try and tell u..
    Visual Studio.net 2010
    If this post is useful, rate it


  11. #11

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Hi Fazi..
    Am getting problem in send message..

    If u have Adobe Profession 7.0 means pls try this...
    1.Open a Pdf File..

    Code:
    OnCommand_Click
    Dim Lng As Long
    Lng = FindWindow(vbNullString, "Adobe Acrobat Professional - [test1.pdf]")
    MenuClick Lng, 3, 10
    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
    This code u only gave me yesterday..
    This not workling...

    Could u say watz the prob...
    Visual Studio.net 2010
    If this post is useful, rate it


  12. #12

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    If i didnt open any file in Adobe means...
    it is...
    Code:
    Lng = FindWindow(vbNullString, "Adobe Acrobat Professional")
    MenuClick Lng, 3, 10
    this working Fine..
    Visual Studio.net 2010
    If this post is useful, rate it


  13. #13
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    ok, i can give a temprary solution. i dont have adobe 7. using 8.
    just find the window handle using a program like winspector spy, Jocim Anderson Window Finder (in VBF code bank) or the program in my signature.
    So if you bring the cursor over tht window, which you want to send the message, you will shown the handle.

    with out using find window, you just put the handle directly in SendMessage.
    check weather your program works as expected. then you can realize what is the trouble. i mean weather you passing the correct window handle or not.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: menuItemExecute

    You might want to try the Adobe SDK and also register as a member (free) as the info they have really helps with this kind of programming as is not really something that allot of developers do outsite their site.

    I have done some development with it under 5.0 and their pdf documentation manuals are really helpful but you need to register in order to download them and accept the disclosure too.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    @ RobDogg

    Ok Rob, I will register and see..
    Visual Studio.net 2010
    If this post is useful, rate it


  16. #16

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    @ Fazi
    ya fine, i will try through winspector spy,
    Window handle id is a constant or it varies.. i watched the value its differing,
    Visual Studio.net 2010
    If this post is useful, rate it


  17. #17

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    @ Fazi..
    FindWindow returning a long value and the sendmessage also get executing but the menu only not executing,,
    i dont know how to check its correct value or not..
    Visual Studio.net 2010
    If this post is useful, rate it


  18. #18
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    Quote Originally Posted by vijy
    @ Fazi
    ya fine, i will try through winspector spy,
    Window handle id is a constant or it varies.. i watched the value its differing,
    Yes, the handles value is not constant. Changes each time...

  19. #19
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    Quote Originally Posted by vijy
    @ Fazi..
    FindWindow returning a long value and the sendmessage also get executing but the menu only not executing,,
    i dont know how to check its correct value or not..
    Then there wan't be a problem with the handle. somthing elase in your code.
    check the return values of Getmenu api's

  20. #20

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    I checked window handle through spy++, its correct only..
    Getmenu too returning values.. But the menu only not executing if any files opened in the Adobe... :-(
    Visual Studio.net 2010
    If this post is useful, rate it


  21. #21
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    GetMenu()
    If the function succeeds, the return value is the handle of the menu.

    GetMenuItemInfo()
    If the function succeeds, the return value is nonzero.
    If the function fails, the return value is zero.

    GetSubMenu()
    If the function succeeds, the return value is the handle of the drop-down menu or submenu activated by the menu item. If the menu item does not activate a drop-down menu or submenu, the return value is NULL.

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: menuItemExecute

    I think without using the Adobe SDK you will continue having issues as its not really designed to be automated this way. You need to use some JavaScript and other scripts inside Adobe and/or the document itself.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    @ RobDogg.
    I googled in adobe for the script of this "Documents", they clearly stated that "Documents menu is not automated"....
    I already did some applications using Adobe scripts..


    @ Fazi.
    Is it possible to execute the menu using process id.... If so means i can execute the Adobe.exe using shell.. and get the process id..
    Visual Studio.net 2010
    If this post is useful, rate it


  24. #24
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    I am not sure about that vijy.
    do your code works with notepad if you change the handle to notepad?
    if its working with notepad and not working with adobe, you have to check what RobDog advised.

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: menuItemExecute

    With the sdk they show how you can execute and even add your own menu items to Adobes menus.

    With using vb you can create the AcroExch.App object and automate the application. Why doesnt MenuItemExecute work for you? Are you sure you have the correct menuitem id for the desired menu item? This is the most proper and stable way to automate Adobe.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  26. #26

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Yes rob, am giving the correct value for menuItemExecute.. Its working fine..



    In pdf, if i didnt opened any file in Adobe means,the menu executing..

    Am getting problem in this case alone " If any pdf file opened in the Adobe,MenuClick not executing "
    Visual Studio.net 2010
    If this post is useful, rate it


  27. #27

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    @ Fazi..
    This working fine in notepad.. Only in Adobe this not working..
    Code:
    Lng = FindWindow(vbNullString, "test1.txt - Notepad")
    MenuClick Lng, 0, 1
    Visual Studio.net 2010
    If this post is useful, rate it


  28. #28
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: menuItemExecute

    I dont have Adobe anymore but if it works fine when a document is opened in it and it doesnt work if there is no document loaded then perhaps the menu item is not available unless there is at least one open document?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  29. #29

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Rob MenuClick works fine if the Adobe doesnt open any pdf files..

    In case 1 MenuClick Working Fine..
    In Case 2, menuClick not working...

    Case 1:
    Code:
    Lng = FindWindow(vbNullString, "Adobe Acrobat Professional")
    MenuClick Lng, 3, 10
    Case 2:
    Code:
    Lng = FindWindow(vbNullString, "Adobe Acrobat Professional - [test1.pdf]")
    MenuClick Lng, 3, 10
    Visual Studio.net 2010
    If this post is useful, rate it


  30. #30
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: menuItemExecute

    Have you used Spy++ to determine the window structure as once documents are opened in it the structure changes. The document opened is a child window and the menu handles may change due to merging of the menus etc. But is the exact window caption in Spy++ as you have it exactly in your code in case #2?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  31. #31

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Rob,
    I googled and got a javascript from Adobe developers for executing menu item..
    I think it will work sound to Here

    Let me try this..
    Visual Studio.net 2010
    If this post is useful, rate it


  32. #32
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: menuItemExecute

    But that is the MenuItemExecute function we discussed earlier in this thread.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  33. #33

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Lng = FindWindow(vbNullString, "Adobe Acrobat Professional - [test1.pdf]")
    this will return the window handle,,

    I checked the winows handle in spy++ along with the value returned from the find window both are different.. ...
    Last edited by vijy; Oct 22nd, 2007 at 03:48 AM.
    Visual Studio.net 2010
    If this post is useful, rate it


  34. #34
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    Deleted.
    Last edited by Fazi; Oct 22nd, 2007 at 05:44 AM.

  35. #35

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Thumbs up Re: menuItemExecute

    I Got the result....
    Thanks Fazi...

    When i opened a file in the Adobe,before the "File" menu,an image(Adobe Logo) is there... I didnt counted the image, When passing menu value in the MenuClick hwnd,menu,....

    If no file opened in pdf means...there is no Logo before the "File" Menu.. This is the problem..

    I attached two images.. jus see it.
    Thanks a lot Rob and Fazi...
    Last edited by vijy; May 23rd, 2008 at 01:15 AM.
    Visual Studio.net 2010
    If this post is useful, rate it


  36. #36

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    Now i want to click "ok" in the dialog Box,.. Could u tell which Api to use pls..
    Visual Studio.net 2010
    If this post is useful, rate it


  37. #37
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    SendMessage Button_handle,BM_CLICK,0,0

  38. #38

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    Re: menuItemExecute

    How to get the Button_Handle of the Particular dialogue box through code???

    FindWindow("Button",vbNullString)
    Last edited by vijy; Oct 22nd, 2007 at 05:43 AM.
    Visual Studio.net 2010
    If this post is useful, rate it


  39. #39
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: menuItemExecute

    This code shows how to obtain the Notepad About box button handle.

    Code:
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    
    Private Sub Command1_Click()
    Dim lngresult As Long
    lngresult = FindWindow(vbNullString, "About Notepad")
    lngresult = FindWindowEx(lngresult, 0&, vbNullString, "OK") 'OK IS THE Button text
    MsgBox lngresult
    End Sub
    Hope this will solve the issue.
    Good Luck
    Last edited by Fazi; Oct 22nd, 2007 at 05:48 AM.

  40. #40
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: menuItemExecute

    A modal dialog window has a special class name of #32770. Use Spy++ to verify it and your level of nesting of the OK button. It may not be the first child window
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width