Results 1 to 31 of 31

Thread: Can't get WORD CHECK SPELLING window to be ON TOP always

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Can't get WORD CHECK SPELLING window to be ON TOP always

    I'm having a problem where the WORD window for CHECK SPELLING doesn't always appear on top of my app.

    I've isolated the code into this simple example - create a new project with two textboxes - TEXT1 and TEXT2 - make both multi-line

    Put this code into FORM1

    Code:
    Public objWord As Object
    
    Private Sub Text1_LostFocus()
        Call CheckSpelling(Text1)
    End Sub
    
    Private Sub Text2_LostFocus()
        Call CheckSpelling(Text2)
    End Sub
    
    Public Function CheckSpelling(t As TextBox)
    On Error GoTo Err_Handler
    
    '    Dim objWord As Object
        Dim objDoc  As Object
        Dim strResult As String
        
        'Create a new instance of word Application
        If (Len(t.Text) = 0) Then
            'nahhhhhhhhhhh
        Else
            App.OleRequestPendingTimeout = 999999
            If objWord Is Nothing Then Set objWord = CreateObject("word.Application")
            objWord.Visible = False
            
            Select Case objWord.Version
                'Office 2000, xp, 2k3
                    Case "9.0", "10.0", "11.0"
                    Set objDoc = objWord.Documents.Add(, , 1, True)
                'Office 97
                    Case Else
                    Set objDoc = objWord.Documents.Add
            End Select
    
            objDoc.Content = t.Text
            objDoc.CheckSpelling
            objWord.Visible = False
            
            strResult = Left(objDoc.Content, Len(objDoc.Content) - 1)
            'correct the carriage returns
            strResult = Replace(strResult, Chr(13), Chr(13) & Chr(10))
    
            If t.Text = strResult Then
                ' There were no spelling errors, so give the user a
                ' visual signal that something happened
                'MsgBox "The spelling check is complete.", vbInformation + vbOKOnly, "Spelling Complete"
            End If
        
            'Clean up
            objDoc.Close False
            Set objDoc = Nothing
            'objWord.Application.Quit True
            'Set objWord = Nothing
    
            ' Replace the selected text with the corrected text. It's important that
            ' this be done after the "Clean Up" because otherwise there are problems
            ' with the screen not repainting
            t.Text = strResult
        End If
    
    Done:
    
    Exit Function
    
    'in case user does not have word...
    Err_Handler:
    MsgBox Err.Description & Chr(13) & Chr(13) & "Please note you must have Microsoft Word installed to utilize the spell check feature.", vbCritical, "Error #: " & Err.Number
    Resume Done
    
    End Function
    Now enter something in TEXT1 and TAB to TEXT2 - so the LOST FOCUS event calls the WORD object to check the spelling.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    I didn't see it at all until I change objWord.Visible = False to objWord.Visible = True and then the word document that text1 got dumped to was displayed, full screen, and on top of everything.

  3. #3

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    You do not want the WORD window to appear itself - just the spell check window. Thus the reason for that being FALSE.

    Alt/Tab will bring the spell check window round front if it doesn't appear so naturally.

    I get it appearing in front - most of the time. Change the app from full screen to partial - I'm trying to find a reason for why it sometimes doesn't appear in front.

    Is it only if you have OUTLOOK open using WORD - or WORD itself open - how can I guarantee that the SPELL CHECK window always appears in front?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    The spell check window itself, for me anyway, pops up as a modal window...I can't get rid of it from being on top unless I close it.

    I have both Outlook and Word open and I ran my test app at partial screen.

    Are there other things going on on your machine that I should try?

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

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    it works well in my pc
    no problem, when tabbing, the spell window appear on top the form as vbmodal.
    what wrong in your system i have word2003

  6. #6

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    It mostly always works for me on my machine - it's my customers that complain about it intermittently.

    Thus they hate it.

    Compile the project. Run the .exe.

    Maximize the window.

    Put dddd into text1 - click tab.

    You will most likely get the SPELL CHECK window to appear.

    Hit ALT/TAB - the SPELL CHECK window disappears and now just the .exe is full screen.

    This is the condition that my clients sometimes have happen - the spell check window is below the app window. I tell them to click ALT/TAB to remedy this - but that is cheesy and they don't like it.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    I don't know why it would go behind sometimes, but I have seen behavior like this before. Could you add some code to always bring it to the front? You could use the BringWindowToTop API.

  8. #8
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    There is a "Always on top" link in my sig, which is pretty much the standard method.

    If it brings it to the top only when the function is called, but it's not on top permanently (very rare), then throw it is a short duration timer (like 500ms).

  9. #9

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Still having this problem...

    Lots of searching the internet today and found this KB article and I'm trying this to see if it works better.

    http://support.microsoft.com/kb/243844/

    I'll post back with results

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

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

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    I tried repositioning Word off screen before when I was developing my Spellchecker but found it added more issues then it solved. If the user opens word during your spellchecking or if there is an issue and it doesnt get repositioned back to original then the user when opens word for normal use will not be able to see it at all since its of screen. If they maximize Word that will present it but then for them to resize it it needs to be normal size but that will position it off screen still. Pain in the butt.
    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

  11. #11

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    wow - that stinks.

    and this is the official MS implementation!

    Maybe I won't reposition it at all - having the WORD doc appear can be explained to 5 users in a law office. It's better then "oh - the spell check window is hidden - just click alt/tab to find it!"

    I found other articles on MSDN that said spell check with WORD was not recommended or supported - I can see why.

    How does ACCESS do the spell check so that it's not buggy?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  12. #12

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

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Quote Originally Posted by szlamany View Post
    How does ACCESS do the spell check so that it's not buggy?
    Probably MS uses its spell checking libraries without needing all of Word.
    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

  14. #14
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    A trick which seem to work is to use SetParent API to make the Word object a child of the form so that the dialog is effectively owned by the form itself. The trick is to catch the creation of the word window and I used Penagates sample for that. You just have to compile the project and put that in your own directory and shell it from there.

    The event the does the job is the following:
    Code:
    Private Sub IShell_WindowCreated(ByVal hWnd As Long)
    Dim sClassName      As String
        sClassName = Space(255)
        
        GetClassName hWnd, StrPtr(sClassName), 255
        
        'check if the word class
        If (Left$(sClassName, 7) = "OpusApp") Then
        
            LockWindowUpdate GetDesktopWindow
            'Hide window
            ShowWindow hWnd, 0
            'set parent to the caller
            SetParent hWnd, callerHandle
            LockWindowUpdate 0
            Unload Me
        End If
        
    End Sub
    And here would be the slight modification to the spell checker procedure.

    Code:
    App.OleRequestPendingTimeout = 999999
    If objWord Is Nothing Then Set objWord = CreateObject("word.Application")
    'shell the exe with together with the handle of the form or a handle of a hidden picturebox control
    Shell "Project1.exe " & Picture1.hWnd, vbHide
    objWord.Visible = True
    
    Select Case objWord.Version
        'Office 2000, xp, 2k3
            Case "9.0", "10.0", "11.0"
            Set objDoc = objWord.Documents.Add(, , 1, True)
        'Office 97
            Case Else
            Set objDoc = objWord.Documents.Add
    End Select
    
    objDoc.Content = t.Text
    objDoc.CheckSpelling
    
    
    'objWord.Visible = False
    Attached Files Attached Files
    Last edited by dee-u; Sep 3rd, 2009 at 10:37 AM.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  15. #15
    New Member
    Join Date
    Jan 2011
    Posts
    6

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    And still a few years later, has anyone managed to solve this one particular annoying problem when hooking into Word's spell check?

  16. #16

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Not that I am aware of. This bothered my clients so much that we abandoned our Winform app and created a web-app with ajax/jQuery and tell them all to use Firefox which has spell check built in.

    I wonder if MS is aware of how bad this looks to users - WORD hidden or messed up by Outlook - yuk,...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  17. #17
    New Member
    Join Date
    Jan 2011
    Posts
    6

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    I've been putting up with this within an internal company app for several years. It's been a unsightly wart on an important internal app in my company. Staff size is small, so I can educate users on resolving a seemingly frozen app during spell check; but now we're moving the app toward a vertical resale market with our clients, and I'll need to get this resolved or replace the functionality. The most frustrating part about it is you can't duplicate it on demand. If you could, somebody could likely provide a work-around.

  18. #18

  19. #19

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    It seems to have even gotten worse with Windows 7 as well - not sure about Windows 8...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  20. #20
    New Member
    Join Date
    Jan 2011
    Posts
    6

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Quote Originally Posted by MartinLiss View Post
    It looks like the code is based on my Spell Check a Textbox that I mentioned above. Take a look at that code and see what's different.
    It's the same code. You even made mention this problem in that other thread, writing:

    "Three problems have been reported by rike when using my code in VBA. Those problems are:

    1. ...
    2. ...
    3 When users try to use other applications while the spellchecker is in progress the screen gets confused and appears to crash."


    As I wrote, I've never figured out how to duplicate it since it's some kind of timing issue. You can simulate the behavior by running in design mode and setting a breakpoint on the .CheckSpelling method, then step to the next line. At least that's how I remember doing it.

  21. #21
    New Member
    Join Date
    Jan 2011
    Posts
    6

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    So years later, looks like this continues to be a flawed means of Spell check.

  22. #22

  23. #23

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    I am sure you could pay dollars for a product that would fulfill your needs in a more robust and bug-free way.

    When life get's tough you just gotta pay your way out...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  24. #24
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Perhaps you'd like to try something else?
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  25. #25
    New Member
    Join Date
    Mar 2014
    Posts
    1

    Red face Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Had this same problem. I used this as a workaround:

    Code:
    'Hide all open forms
              For Each f As Form In My.Application.OpenForms
                      f.Hide()
              Next
    
              doc.Activate()
              doc.CheckSpelling()
    
              'Show all forms after spell check
               For Each f As Form In My.Application.OpenForms
                     f.Show()
               Next
    It's more of a workaround than anything.

    - Mark

  26. #26

  27. #27

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    And a thread that is 15 months old

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  28. #28
    New Member
    Join Date
    May 2022
    Posts
    6

    SOLVED: Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    I solved this.
    When you are testing the spellchecker with vb6 running. The spellchecker stays at the back.
    You need to first make all of your open application forms invisible like this.
    UserForm1.visible = false
    UserForm2.visible = false.
    Then call the activedocument.spellchecker
    Then make all your forms visible again
    after spellchecker is finished.
    Now when you make the executable file and test it with vb6 closed, the word document will be in front with the spellchecker also in front.

  29. #29
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    You do realize that this thread is 13 years old?
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  30. #30
    Hyperactive Member deathfxu's Avatar
    Join Date
    Mar 2009
    Location
    USA
    Posts
    279

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Quote Originally Posted by Niya View Post
    You do realize that this thread is 13 years old?
    I also appreciate his dedication to getting the correct answer. Good job Code Tech!

    We should work on this until 2034. It is the only way to be sure.

    !remindme in 12 years

  31. #31
    New Member
    Join Date
    May 2022
    Posts
    6

    Re: Can't get WORD CHECK SPELLING window to be ON TOP always

    Guess I been sleeping that long. LOL
    Actually I just pulled out an old VB6 application that I wrote so that I could convert it to vb.net but I had to fix the spellchecker issue 1st.

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