Click to See Complete Forum and Search --> : Annoying wordpopup window 'Save changes?' stays on the back
lvermeersch
Jun 17th, 2006, 03:04 AM
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?
RobDog888
Jun 17th, 2006, 09:50 AM
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.
lvermeersch
Jul 6th, 2006, 02:01 AM
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.
westconn1
Jul 6th, 2006, 02:53 AM
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
lvermeersch
Jul 6th, 2006, 05:17 AM
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.
westconn1
Jul 6th, 2006, 05:22 AM
maybe your program could poll for the savechanges messagebox and change from topmost so it can display, then back to topmost
pete
lvermeersch
Jul 6th, 2006, 05:53 AM
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.
westconn1
Jul 6th, 2006, 08:02 AM
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
lvermeersch
Jul 6th, 2006, 09:31 AM
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 .
AppWord.DisplayAlerts = wdAlertsNone
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.