Results 1 to 9 of 9

Thread: Annoying wordpopup window 'Save changes?' stays on the back

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Annoying wordpopup window 'Save changes?' stays on the back

    I use Word automation in my VB6 application.
    I have a starting form running and is open showing mostly on the right of my screen. The open word window is mostly shown left on screen. But both windows do overlap eachother.
    Now when user closes a word document, a popup window is shown by word itself saying 'Do you want to save the changes ?'.
    Now problem is mostly this window is displayed behind my vb Form! This is very annoying for the user. Can i work around this. My vbform is set on top , which is necesarry.

    I know in VB , with a msgbox you can use vbSystemModal to always keep a msgbox on top. Maybe there is e setting in word as well to give it's messages on top?

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

    Re: Annoying wordpopup window 'Save changes?' stays on the back

    Since you already have your vb form set to always on top you can not get word to display its msgbox on top at all unless you removed the on top for the vbform temporarily and then sall the .SaveAs or what ever yoiur calling in word, let the user save it, then reaply the ntop for your vb form.
    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: Annoying wordpopup window 'Save changes?' stays on the back

    I understand, so i have to find an other solution.
    Maybe there is a word setting to completely avoid the message 'do you want to save changes?'
    On internet i found a command warnifformdirty. Does this exists?
    Or is there other setting.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Annoying wordpopup window 'Save changes?' stays on the back

    yes you can bypass the do you want to save changes, but then you have to always save changes or never save changes.
    you can put code in document close to override the settings, this runs before the messagebox
    if activedocument.saved = true, then you won't get prompted to save changes
    so you can change the setting, or save the document, which will also change the setting,
    or put any other code you want

    pete

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Re: Annoying wordpopup window 'Save changes?' stays on the back

    I put following codeline in a command button
    AppWord.Activedocument.Saved = true

    So now i can make changes , then push the command button then when i close word it will not ask for the 'Do you want to save changes'. But I think a can't use that.
    In that case i constantly have to set the saved to true after user makes changes.
    And i don't want to make use of the word events close or other for different reasens.
    Is there an other solution. I think i need some general word setting here. Or a way to prevent from getting the Save changes window or putting it on top. Hum so not that simple.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Annoying wordpopup window 'Save changes?' stays on the back

    maybe your program could poll for the savechanges messagebox and change from topmost so it can display, then back to topmost

    pete

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Re: Annoying wordpopup window 'Save changes?' stays on the back

    Yes, i allready thought about that and find this a good approach. But how to go about this.
    Changing my vb form top most is easy but getting the correct window handle of save changes window is difficult.
    I can get the window handle, i used a spy program to get the code.
    Like
    hendle = FindWindow("#32770",vbnullstring)
    But i have read 32770 is a comman used in many windows. Checking windowtitle
    or even the label caption allso is not unique and i have to support differert word versions and languages. (so there is no mistake when an other simular window is open)
    Or am i making it to difficult is there an easier way to get the handle of that specific 'save changes' window. Thanx for your help.

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Annoying wordpopup window 'Save changes?' stays on the back

    if you can get the handle, then check the window title, or even the contents, to comfirm it is the right one.

    come to that does it matter even if it is dialog from a different app. good to let it get the focus for user response.

    pete

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Re: Annoying wordpopup window 'Save changes?' stays on the back

    The window title is just 'Microsoft Word'. So that's possible to check the window title i think. If several windows are open it's just the correct one that has to get on top. But in this case no problem i suppose.

    Allsso i got following tip from someone i maybe could use DisplayAlerts .
    VB Code:
    1. AppWord.DisplayAlerts = wdAlertsNone
    2. AppWord.Documents.Open(”C:\Klad\TestFile.doc”)
    Altough it has no effect at all. Or i am using it wrong
    I allso tried
    Appword.Activewindow.application.DisplayAlerts = wdAlertsNone
    or
    Appword.Activedocument.application.DisplayAlerts = wdAlertsNone
    And no effect. Word still asks 'Do you want to save'
    I will try the window handle en title later.

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