AutoRecovery Problem

T

Terry

Could somebody provide some advice on this issue?
What I'm trying to acheive is automate Words startup so that Word opens with
no document open and the user then is provided with a menu offering some
predefined templates.
This all works fine, the problem is the AutoRecovery issue. When Word
reopens after a crash, the autorecovery file flashes before you and then
gets closed.
I'm trying to trap this in code, but this is where i'm having difficulty,
here is the code which resides in the autoexec on startup.

If Documents.Count = 1 Then
If InStr(1, ActiveDocument.Name, "Recovered", vbTextCompare) = 0 Then
ActiveDocument.Close wdDoNotSaveChanges
End If

The purpose of this code is to close any open document unless its a
recovered one.
The document which autorecovery puts back is named something like "Document
1 (Recovered)" but the InStr function only sees the 1st part of the document
name and so doesnt recognise the autorecovery and closes the document.
Can anyone suggest a way around this?
 
C

Chad DeMeyer

Terry,

You would have to test this to be sure, but I believe a recovered document
could be tested for in the same way that a new document can:

If ActiveDocument.Path = "" Then
'New (or recovered) document
Else
'Previously saved document
End If

Regards,
Chad
 
T

Terry

Thanks Chad,
I have, however, devised another way of doing it.
Instead of testing ActiveDocument.Name , I test
Options.DefaultFilePath(wdAutoRecoverPath) for the existance of an asd and
branch accordingly.
 

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