FileSave makes me crazy !!

H

Hans Troost

Hi All,

Using Word 2002, in a large and complex add-in (loaded with the
/L-commandline switch) I have a class module to intercept events and
modules with a lot of routines. One of the (public) routines is
FileSave() and in the class module I also intercept the
DocumentBeforeSave.

I have the following strange behaviour:

When Closing the document (also intercepted) and Word QUIT
(intercepted) and the document not saved: my specific FileSave is
nicely executed, after the DocumentBeforeSave event.

But (and this is the problem): when explicitly clicking the default
Save button (on the default Word-toolbar) or using the File-->Save
menu it does not execute FileSave.

What happens is the following;

The first time I press <Save> I see that the document is being saved
(simply see it happen on the screen and see the file time-stamp): The
LOG-file just shows:
11-08-03 14:40:01 DocumentBeforeSave start
11-08-03 14:40:01 WHT007000.TMP .saved: False
11-08-03 14:40:01 DocumentBeforeSave end
So the FileSave-routine is not executed while the file is saved (as
should be: doc.saved = False) !!! (I also update an Oracle database
with SetExpId in the FileSave and this did not happen)

The second atime the LOG-file shows:

11-08-03 14:40:04 DocumentBeforeSave start
11-08-03 14:40:04 WHT007000.TMP .saved: True
11-08-03 14:40:04 DocumentBeforeSave end

indicating that (indeeed the first time the document is really saved (
doc.saved = True)

Typing something in the document (.saved to become False now) en
pressing File-->Save shows on the screen the saving be done and in the
LOG-file:
11-08-03 14:40:10 DocumentBeforeSave start
11-08-03 14:40:10 WHT007000.TMP .saved: False (correct)
11-08-03 14:40:10 DocumentBeforeSave end

Since the first "real command" in FileSave is writing to the LOG-file
I should at least see a line with "<time-stamp> FileSave start" in the
LOG-file


This makes me ccompletely crazy: Why is the FileSave not executed???

I would be very pleased if someone can help me out.

Best regards,

Hans Troost

My DocumentBeforeSave is this:
Private Sub ActiveApp_DocumentBeforeSave(ByVal Doc As Document,
SaveAsUI As Boolean, Cancel As Boolean)
<write to LOG-file> "DocumentBeforeSave start"
<write to LOG-file> Doc.Name & " .saved: " & IIf(Doc.Saved,
"True", "False")
<write to LOG-file> "DocumentBeforeSave end"
End sub

and FileSave:
'
' FileSave Macro: intercepts the regular word SAVE command
' Saves the active document or template
'
Dim strDocFullName As String
Dim strDocName As String
Dim strExpID As String

'
' FileSave Macro: intercepts the regular word SAVE command
' Saves the active document or template
'
Dim strDocFullName As String
Dim strDocName As String
Dim strExpID As String

<write to LOG-file> "FileSave start"
<write to LOG-file> "File to be saved: " & ActiveDocument.FullName
<write to LOG-file> "Re-open: " & IIf(blnReOpen, "True", "False")

strDocFullName = ActiveDocument.FullName
strDocName = ActiveDocument.Name

If blnReOpen Then
With frmTMP2Doc
.lblInfo.Caption = "First time saving of experiment " &
Left(strDocName, 9) _
& vbNewLine & vbNewLine _
& "The document will be closed and re-opened"
.Show
End With
End If

ActiveDocument.Save
If IsHellasDoc(ActiveDocument) And Right(strDocName, 4) = ".TMP"
Then
ActiveDocument.Close
Call MyFileCopy(strDocFullName, gcolSettings(gcstrWorkDir) &
Left(strDocName, 9) & ".doc")
Call Kill(strDocFullName)
Call SetExpId ' increase the LastExp field in table
HELLAS_USERS in the database
If blnReOpen Then
Call DoOpenExp(Left(strDocName, 9) & ".doc",
gcolSettings(gcstrWorkDir))
End If
End If

If blnReOpen Then
Unload frmTMP2Doc
End If
<write to LOG-file> "FileSave end"

End Sub
 
M

martinique

The Save toolbar button doesn't use the 'FileSave' command; it uses a
command called FileSaveDefault.
 
H

Hans Troost

martinique said:
The Save toolbar button doesn't use the 'FileSave' command; it uses a
command called FileSaveDefault.
Hello Martinique,

Thanks for your willingness to help me, I'm all the time very pleased
that you and people like you spent their time to assist developpers...

With high hopes I tried your suggestion: use FileSaveDefault.
Unfortunately it did not work.

So I checked the list of macro's that intercept Word commands
(Tools-->Macros, choosed for Macro's in Word Commands and did not find
FileSaveDefault.

Tried another thing:
Wrote this little module:
=====================================
Sub FileSave()

MsgBox ActiveDocument.Name, vbInformation, "FileSave"
ActiveDocument.Save

End Sub
Sub FileSaveDefault()

MsgBox ActiveDocument.Name, vbInformation, "FileSaveDefault"
ActiveDocument.Save

End Sub

Sub FileSaveAs()

MsgBox ActiveDocument.Name, vbInformation, "FileSaveAs"
Dialogs(wdDialogFileSaveAs).Show

End Sub
====================================
saved in in a template and used it by loading it as an add-in
(/L<templ-name>).

Starting Word with this add-in, typing something in the new document
and clicking the Save button (or File-->Save or <ctrl>+s) Pops up the
FileSave messagebox and not the FileSaveDefault.

In fact I never succeeded in firing FileSaveDefault and I think it
does not exist (only 1 W97-VBA article and nothing more about it on
the Web/News etc). I use Word 2002.

Added the FileSaveAs just as extra check: this also works with File-->
Save As.

So my question still remains: why does FileSave not work in my (big)
add-in, while - as far I know - do not prevent this in one way or
another (I even don't know how, in case I would...). Since the code is
very big and needs a lot of explanation it is not helpfull to hand it
over. I'm looking for suggestions of "possible causes".

This problem is very urgent and becomes a project "show-stopper", when
I fail to solve it. So any help is welcome: I will try any
suggestion!!

Regards,

Hans
 
H

Hans Troost

Hello Martinique,

martinique said:
The Save toolbar button doesn't use the 'FileSave' command; it uses a
command called FileSaveDefault.
Thanks for your willingness to help me, I'm all the time very pleased
that you and people like you spent their time to assist developpers...

With high hopes I tried your suggestion: use FileSaveDefault.
Unfortunately it did not work.

So I checked the list of macro's that intercept Word commands
(Tools-->Macros, choosed for Macro's in Word Commands and did not find
FileSaveDefault.

Tried another thing:
Wrote this little module:
=====================================
Sub FileSave()

MsgBox ActiveDocument.Name, vbInformation, "FileSave"
ActiveDocument.Save

End Sub
Sub FileSaveDefault()

MsgBox ActiveDocument.Name, vbInformation, "FileSaveDefault"
ActiveDocument.Save

End Sub

Sub FileSaveAs()

MsgBox ActiveDocument.Name, vbInformation, "FileSaveAs"
Dialogs(wdDialogFileSaveAs).Show

End Sub
====================================
saved in in a template and used it by loading it as an add-in
(/L<templ-name>).

Starting Word with this add-in, typing something in the new document
and clicking the Save button (or File-->Save or <ctrl>+s) Pops up the
FileSave messagebox and not the FileSaveDefault.

In fact I never succeeded in firing FileSaveDefault and I think it
does not exist (only 1 W97-VBA article and nothing more about it on
the Web/News etc). I use Word 2002.

Added the FileSaveAs just as extra check: this also works with File-->
Save As.

So my question still remains: why does FileSave not work in my (big)
add-in, while - as far I know - do not prevent this in one way or
another (I even don't know how, in case I would...). Since the code is
very big and needs a lot of explanation it is not helpfull to hand it
over. I'm looking for suggestions of "possible causes".

This problem is very urgent and becomes a project "show-stopper", when
I fail to solve it. So any help is welcome: I will try any
suggestion!!

Regards,

Hans
 
B

Bill Bowen

Hans,

We are currently tracking the
Application.Dialogs(wdDialogFileSaveAs).Show call as being very buggy
in Word 2002. We are experiencing instances where the dialog closes
giving the illusion that files have been saved when they have not.
Taking out this call appears to allow the document to save (though
doesn't display the dialog obviously).

I can't give you any more as I'm just beginning to test this. I'll
keep you posted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top