Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2003
    Location
    Sydney, New South Wales, Australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Substituting my docname for Document1.doc (Word)

    Our office has strict file naming standards and I'd like to implement them within our template structure. When a new document opens, it is called Document(n).doc. Is there any way to change this? I'm thinking of some appropriate code in the AutoNew macro. I can't change ActiveDocument.Name because that is a read-only attribute and I don't want to use SaveAs if I can avoid it, as the user may not want to save the document yet. Actually, I don't much care about the document name when opened, it should have the suggested name in the SaveAs dialog box when the user does save though. Any ideas?

    Jeff.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Substituting my docname for Document1.doc (Word)

    You can override the built-in action of File | Save and File | SaveAs... by creating macros named FileSave and FileSaveAs. For example:

    Sub FileSaveAs()
    With Dialogs(wdDialogFileSaveAs)
    If InStr(ActiveDocument.FullName, "") = 0 Then
    .Name = "MyDoc"
    End If
    .Show
    End With
    End Sub

    Sub FileSave()
    If InStr(ActiveDocument.FullName, "") = 0 Then
    FileSaveAs
    Else
    ActiveDocument.Save
    End If
    End Sub

    The macros test if a document has never been saved by looking for a backslash in the full name. Instead of a fixed name ("MyDoc.doc"), you can use a variable. If you store these macros in a template, they will be used by all documents based on that template; if you put them in a global template, they will be used by all documents unless overridden.

    If you like, you can set the caption of the active window in Document_New (or AutoNew), but that won't influence the siggested name for saving.

  3. #3
    New Lounger
    Join Date
    Jun 2003
    Location
    Sydney, New South Wales, Australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Substituting my docname for Document1.doc (Word)

    Hans, that looks just fantastic. I'm very grateful.

    Many, many thanks... Jeff.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •