Results 1 to 15 of 15
  1. #1
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Save with no file name (Word 2003)

    When you save a new document in Word it takes the first bit of text for the file name. Is it possible to force Word to leave th file name blank when saving the document?

    Kerry

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Save with no file name (Word 2003)

    You could intercept the Save and SaveAs commands and replace them with
    <code>
    Sub MySaveAs()
    With Application.FileSearch
    .FileName = ActiveDocument.Name
    .LookIn = ActiveDocument.Path
    .Execute
    If .FoundFiles.Count = 0 Then
    With Application.Dialogs(wdDialogFileSaveAs)
    .Name = ""
    .Show
    End With
    Else
    Application.Dialogs(wdDialogFileSaveAs).Show
    End If
    End With
    End Sub
    </code>

    StuartR

    Edited by StuartR to replace the code with a version that checks if the current document has a corresponding file.

  3. #3
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Save with no file name (Word 2003)

    I really want to use it in a document that I have saved and set the property to "read only". When the user choses to save the document I dont want it to use the file name and then have them presented with Words Standard pop up saying that this file is Readonly and you cant save the file with the same name etc.

    Kerry

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Save with no file name (Word 2003)

    I'm a little confused now. Do you want this for NEW documents and Read-Only documents, or for read-only documents only?

    You could do the same intercept but instead of the check for the file existing you could have a much simpler check for
    <code>
    If ActiveDocument.ReadOnly then
    ...
    End If
    </code>
    StuartR

  5. #5
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Save with no file name (Word 2003)

    I want it for saving a Read Only document.

    Kerry

  6. #6
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Save with no file name (Word 2003)

    So how would this read for a read only file?


    Sub MySaveAs()
    With Application.FileSearch
    .FileName = ActiveDocument.Name
    .LookIn = ActiveDocument.Path
    .Execute
    If .FoundFiles.Count = 0 Then
    With Application.Dialogs(wdDialogFileSaveAs)
    .Name = ""
    .Show
    End With
    Else
    Application.Dialogs(wdDialogFileSaveAs).Show
    End If
    End With
    End Sub

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

    Re: Save with no file name (Word 2003)

    Does this do what you want?

    Sub MySaveAs()
    With Application.Dialogs(wdDialogFileSaveAs)
    If ActiveDocument.ReadOnly = True Then
    .Name = ""
    End If
    .Show
    End With
    End Sub

  8. #8
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Save with no file name (Word 2003)

    I placed it in a module of its own and it doesnt seem to work. On a read only document it still presents with the filename tos ave as instead of a blank file name. Am I dong something wrong?

    Kerry

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

    Re: Save with no file name (Word 2003)

    The macro doesn't run by itself. As Stuart suggested, you must intercept the File | Save and File | Save As... commands. Add the following code to the module:

    Sub FileSave()
    MySaveAs
    End Sub

    Sub FileSaveAs()
    MySaveAs
    End Sub

  10. #10
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Save with no file name (Word 2003)

    Thanks Hans - that works. Much appreciated.

  11. #11
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Save with no file name (Word 2003)

    Hi there

    I have been merrily working away with this solution and now discovered that if the user uses the X to close the file they are asked if they want to save the file using the current file name. I want to avoid this in the same way as I do with the Save As and Save method. How can I do this.

    Kerry

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

    Re: Save with no file name (Word 2003)

    It can probably be done using application level events, but I'd recommend to let it be. Intercepting the document and application close buttons has been discussed at length in the past, and it turns out to be very difficult to control what exactly happens when the user clicks one of these - the order in which various events occur cause prompts to be displayed in an unexpected sequence, or to be displayed multiple times. Moreover, using application level events is fragile - if an error occurs, they stop working.

  13. #13
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Save with no file name (Word 2003)

    It's even worse than you have found out so far, have a look at replies to <post:=243,841>post 243,841</post:>.

    StuartR

  14. #14
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Save with no file name (Word 2003)

    I think you might be working too hard to avoid the annoying prompt. After all, if you want to encourage people to use the Save / SaveAs commands -- because people should save regularly -- rather than rely on Close/Exit, making the latter more annoying isn't such a bad idea. <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

  15. #15
    4 Star Lounger
    Join Date
    Apr 2002
    Location
    Northern Territory, Australia
    Posts
    471
    Thanks
    16
    Thanked 0 Times in 0 Posts

    Re: Save with no file name (Word 2003)

    Wouldn't it be a dream if everyone did it the way I wanted!!!

    Yes I do spend a lot of time trying to avoid having "computer illiterate" users hitting buttons that present them with questions they DONT read.

    I can see that this one is going to be in the too hard basket. I can live with it.

    Thanks All

    Kerry

Posting Permissions

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