H
Hans Troost
Hi All,
In my complex WORD-2002 add-in (loaded with the command-line
/L-switch) I call a FileSave routine.
Main-function: if the document is a temporary one (extension *.TMP),
close it, copy it to <same name>.doc and open the *.doc file
afterwards.
The form that pops up is just for user-information
This routine does exactly what I intended, but everytime it is
executed, WORD crashes and the famous WORD recovery screen pops up ,
(starting with "Microsoft Word has encountered a problem and needs to
close. We are sorry for the inconvenience."
I already tried to avoid timing/buffering problems by adding extra
lines like DoEvents and Application.ScreenRefresh (marked with --> in
the code below).
This did not help.
Why does WORD 2002 crash after such a simple routine?
Best regards,
Hans Troost
Public Sub FileSave(Optional ByVal blnReOpen As Boolean = False)
'
' 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
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
--> Call Application.ScreenRefresh
--> DoEvents
End If
ActiveDocument.Save
If IsHellasDoc(ActiveDocument) And Right(strDocName, 4) = ".TMP"
Then
ActiveDocument.Close
--> DoEvents
--> Call Application.ScreenRefresh
--> DoEvents
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))
--> Call Application.ScreenRefresh
--> DoEvents
Unload frmTMP2Doc
--> Call Application.ScreenRefresh
--> DoEvents
End If
End If
--> DoEvents
End Sub
In my complex WORD-2002 add-in (loaded with the command-line
/L-switch) I call a FileSave routine.
Main-function: if the document is a temporary one (extension *.TMP),
close it, copy it to <same name>.doc and open the *.doc file
afterwards.
The form that pops up is just for user-information
This routine does exactly what I intended, but everytime it is
executed, WORD crashes and the famous WORD recovery screen pops up ,
(starting with "Microsoft Word has encountered a problem and needs to
close. We are sorry for the inconvenience."
I already tried to avoid timing/buffering problems by adding extra
lines like DoEvents and Application.ScreenRefresh (marked with --> in
the code below).
This did not help.
Why does WORD 2002 crash after such a simple routine?
Best regards,
Hans Troost
Public Sub FileSave(Optional ByVal blnReOpen As Boolean = False)
'
' 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
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
--> Call Application.ScreenRefresh
--> DoEvents
End If
ActiveDocument.Save
If IsHellasDoc(ActiveDocument) And Right(strDocName, 4) = ".TMP"
Then
ActiveDocument.Close
--> DoEvents
--> Call Application.ScreenRefresh
--> DoEvents
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))
--> Call Application.ScreenRefresh
--> DoEvents
Unload frmTMP2Doc
--> Call Application.ScreenRefresh
--> DoEvents
End If
End If
--> DoEvents
End Sub