Results 1 to 3 of 3

Thread: Getting handle subwindow Word document, STRANGE BEHAVIOR

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Getting handle subwindow Word document, STRANGE BEHAVIOR

    I use Word automation in my VB6 Application
    I have to get the handle to a subwindow of an open Word document let say the textbox properties window.
    I found how to do it but couldn't get the handle (i get allways zero)
    I can only get the handle to he parent word document OpusApp.

    The code
    'I know i have the correct 10.0 version
    VB Code:
    1. Hendel = FindWIndowEx(0,0,"bosa_sdm_Microsoft Word 10.0","")

    So i get allways zero and i have the submenu 'FormatTexbox' open
    I can get the hendle using GetForegrondwindow but, using this method is useless here, because i have to find the window through the open windows not only the foreground or active one.

    Should i use an other API, to look for the submenu class or am i doing something wrong.
    Last edited by lvermeersch; Dec 16th, 2005 at 09:14 AM.

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

    Re: Getting handle subwindow Word document

    You need to pass the found parent window handle (OPusApp) so it knows to look for a child window of that window.
    VB Code:
    1. Hendel = FindWIndowEx(WordHandleGoesHere,0,"bosa_sdm_Microsoft Word 10.0","")
    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

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Re: Getting handle subwindow Word document

    Thx for reply.I can get the handle now most of the time. But sometimes get nothing.
    I found a very strange behavior. Problem seems to be an execute stop, the command FindWindowEx seems not the problem.

    First my situation.
    I have a timer (interval at 50)
    In the timer i look for the open subwindow using the FindWindowEx command
    The problem seems te be that when i open a Save As window in the open Word document sometimes (in 50% of the case) the timercode stops executing. To check this i add a static counter with a textbox. Often the Tel counter doen'st add but stops until i close the doc subwindow 'Save as', then the counter continues?
    What can i do about this. I need to continue my code in the timer when subwindow is open. The same effect when i open subwindow Options or other subwindow. Allso setting a shorter timerinterval doesn't improve
    -Allso strange is that when the cursor is in a textbox shape of word doc it does allways work!
    When cursor is just in the word document itself and not in a textbox or other object this not allways work and executing often stops until i close the subwindow.


    VB Code:
    1. Private SUb Timer1_Timer()
    2.   Static Tel as Long
    3.   Dim Hendel as Long
    4.   tel = tel + 1
    5.   text22.text = tel
    6.    Hendel = FindWindowEx(...)
    7. end sub

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