• Test whether document have ever been saved (Word97/NT)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Test whether document have ever been saved (Word97/NT)

    Author
    Topic
    #429015

    Hi

    How do I test to see whether a document has ever been saved? (I’m sure it’s been covered before, but I can’t find it.) I thought ActiveDocument.Path would do it, but I’m now looking at a never-saved document that has a path of “H:”???

    Thanks
    Dale

    Viewing 0 reply threads
    Author
    Replies
    • #998089

      That’s strange, ActiveDocument.Path should be blank for a new document. You could test whether the name contains a point (from the extension):

      If InStr(ActiveDocument.Name, “.”) > 0 Then
      ‘ Document has been saved
      Else
      ‘ Document hasn’t been saved
      End If

      • #998093

        False alarm, Hans. I wanted to force the user to save the document, so I tested the Path then issued an ActiveDocument.FileAs. (Wrong, Dale, should have been a “Dialogs (wdDialogFileSaveAs)”.) Surprisingly (to me), Word now saves the document with a name of its choice in a folder of its choice (in this case, H:).

        Ah well, I’ll use the Dialogs statement (as I should have done in the first place), and it looks like Path remains a good test for never-savedness.

        Sorry for the blunder
        Dale

        • #998591

          At the risk of stating the obvious, doesn’t checking the “Saved” property do what you need? (“If ActiveDocument.Saved = False Then…”) Or, since it’s Word 97/NT, wasn’t there a property along the lines of “IsDirty”… I recall having to use that sometime in the past.

          • #998593

            Dale’s question was whether the document had ever been saved. The Saved property of a document only tells you whether it has been changed since the last save. If you open an existing document, and modify something, Saved will be False.

            • #998596

              D’oh! doh I should have listened to that little voice…

    Viewing 0 reply threads
    Reply To: Test whether document have ever been saved (Word97/NT)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: