Ozgrid Excel Help Forums & Excel Best Practices


XL Templates | XL Add-ins | XL Training | XL Estimating | XL Scheduling | XL Recovery | XL Trading | XL Financial | XL Conversion | XL Charting


<
+ Reply to Thread
Results 1 to 4 of 4

Thread: Auto SaveAs with certain filename

  1. #1
    Join Date
    8th May 2003
    Location
    the Med Sea
    Posts
    122

    Auto SaveAs with certain filename

    Hi all,

    I am working on a template. Users should open this template and then make some changes and save it as "Invoice 01", "Invoice 02", "Invoice 03", etc.
    Is there any way to change the name (usually "doc1.doc") that Word suggests in the "File-Save As" window to something different?

    Thank you all for any help,
    Best,

    Balangan

  2. #2
    Join Date
    25th May 2005
    Location
    St. Clair Shores, MI, USA
    Posts
    145

    Re: Auto SaveAs with certain filename

    I have much the same question:

    DOES ANYONE KNOW HOW TO CHANGE THE DEFAULT FILENAME THAT APPEARS IN THE SAVE AS DIALOG BOX IN Microsoft WORD?

    My goal is to present the PossibleFileName to the user in the SaveAs dialog box. PossibleFileName will be generated by other parts of the code. The user can then view and change this to a ChosenFileName within the SaveAs dialog box.

    Code:
    'The following code will display the Microsoft Word Save As dialog box
    'but unfortunately doesn't allow the default file name to be changed.
    'Its default is the filename of the document which contains the control
    'which launched it.
        Dialogs(wdDialogFileSaveAs).Show
    
    'The following code will save the document, but unfortunately doesn't
    'show the Save As dialog box first.
        ActiveDocument.SaveAs ChosenFileName, xlDocumentNormal
    
    ' IN MICROSOFT EXCEL, THIS IS RELATIVELY EASY TO DO 
    ' WITH CODE LIKE THE FOLLOWING:
        ChosenFileName = Application.GetSaveAsFilename_
             (PossibleFileName, "Excel Files (*.xls),*.xls,", , "Title")
        ActiveWorkbook.SaveAs ChosenFileName, xlWorkbookNormal
    The GetSaveAsFileName application does not work in Word.
    Does Anyone know of how to control the Dialogs(wdDialogFileSaveAs) in Word to change the filename it first shows?

  3. #3
    Join Date
    14th July 2004
    Posts
    9,800

    Re: Auto SaveAs with certain filename

    If you look in help you will see that the FileSaveAs dialog can take the following
    arguments.
    Name, Format, LockAnnot, Password, AddToMru, WritePassword, RecommendReadOnly, EmbedFonts, NativePictureFormat, FormsData, SaveAsAOCELetter, WriteVersion, VersionDesc
    Perhaps something like this.
    Code:
    With Dialogs(wdDialogFileSaveAs)
        .Name = "mydoc.doc"
        .Show
    End With

  4. #4
    Join Date
    25th May 2005
    Location
    St. Clair Shores, MI, USA
    Posts
    145

    Re: Auto SaveAs with certain filename


    Create Excel dashboards quickly with Plug-N-Play reports.
    Thank you,

    I found that this works:

    Code:
     With Dialogs(wdDialogFileSaveAs)
        .Name = PossibleFileName    'whatever you want it to display under FileName in the DialogFileSaveAs dialog box.
        .Display                    'displays the dialog box - at this point the user can make changes.
        .Execute                    'actually saves it with whatever final filename the user chooses.  By default, its a .doc file extension
     End With
    
    'maybe there's a cleaner way to get the name back that the user picked, but this works:
    
    'returns the name including the .doc extension
    ChosenFileNameandExtension = ActiveDocument.Name
    'gets character length of string counting the .doc extension
    LengthofChosenFileNameandExtension = Len(ChosenFileNameandExtension)
    'trims off the four characters consisting of ".doc"
    ChosenFilename = Left(ChosenFileNameandExtension, LengthofChosenFileNameandExtension - 4)
    
    MsgBox ChosenFilename
    Last edited by macromike; January 24th, 2006 at 05:33.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Possible Answers

  1. Replies: 1
    Last Post: February 25th, 2007, 02:28
  2. SaveAs-filename and location
    By JumJewel in forum EXCEL HELP
    Replies: 2
    Last Post: September 15th, 2005, 05:45
  3. Saveas condition if filename true
    By Bradford in forum EXCEL HELP
    Replies: 3
    Last Post: August 5th, 2005, 00:07
  4. Error in SaveAs Filename
    By fho1 in forum EXCEL HELP
    Replies: 2
    Last Post: October 17th, 2004, 06:01
  5. SAVEAS-include a date in a cell to filename.
    By DANDERSON in forum EXCEL HELP
    Replies: 2
    Last Post: August 10th, 2004, 05:05

Bookmarks

Posting Permissions

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