Word-2002 crashes with this FilesSave routine

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
 
C

Cindy Meister -WordMVP-

Hi Hans,
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.
Where is this *.tmp file coming from?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
C

Cindy Meister -WordMVP-

Hi Hans,

Word uses the TMP extension, itself, for its scratch files. I'm
concerned that this may be causing your program some problems. Try
using a different extension for your temporary files and see if that
changes anything?
Workflow: The user creates a new Experiment based on a template (so a
new document) or by copying an existing one, and then in both cases
the TMP-file comes from: Call <application
class>.ActiveDoc.SaveAs(strNewDocName), where strNewDocName for
example is: WHT001300.TMP.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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