Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    File save as name (VBA / Access+Word 2000)

    Hi everyone
    I have some code that generates a Word document (from Access VBA), and then leaves it on the screen (as 'Document1') for the user to edit and then save. (The document is not saved by code.) I want to set a default filesave name (that they could change when they save). I've found that Word uses the template's title (if it has one) as the default save as name. Changing the new document's title doesn't change it's default save as name.
    Any ideas how I can set the default file saveas name?
    Thanks
    Peter

    <pre>Dim wd As Object
    Dim doc As Word.Document

    Set wd = CreateObject("Word.Application")
    Set doc = wd.Documents.Add(Template:="blahblahthing.dot")

    With doc
    'This sets the document's title, but Word uses the original title for the
    'default filesave name.
    .BuiltInDocumentProperties(wdPropertyTitle) = "WeeklyReport" & _
    "For" & UCase(sOfficer) & _
    Format(dSTart, "d-mmm-yy") & "To" & Format(dEnd, "d-mmm-yy")
    ...
    wd.Visible = True
    doc.Activate
    </pre>


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

    Re: File save as name (VBA / Access+Word 2000)

    Try this:
    <code>
    With wd.Dialogs(wdDialogFileSummaryInfo)
    .Title = "Weekly Report For " & UCase(sOfficer) & " " & _
    Format(dSTart, "d-mmm-yy") & " To " & Format(dEnd, "d mmm yy")
    .Execute
    End With
    </code>
    Note that I replaced the dashes in the date format with spaces. Dashes and underscores don't work. See How to set the default suggested filename to be displayed by the Save As dialog the first time a user saves a new document on the Word MVP site.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    251
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Thanks

    Superb! Thank you so much! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

Posting Permissions

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