Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Jun 2001
    Location
    Vancouver, Br. Columbia
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Rename the File>Open dialog (Word 2003)

    I am using the following code to perform a File/New, but using the File>Open dialog, which works perfectly. Is there a way to rename the dialog so it says, for example, "New from Precedent", instead of "Open"?

    Dim docNew As Document
    Options.DefaultFilePath(Path:=wdDocumentsPath) = LitTemplatePath
    With Dialogs(wdDialogFileOpen)
    If .Display = True Then
    Set docNew = Documents.Add(Template:= _
    Options.DefaultFilePath(wdCurrentFolderPath) & _
    Application.PathSeparator & Replace(.Name, """", ""), _
    Visible:=True)
    docNew.Activate
    Set docNew = Nothing
    End If
    End With

    Thanks...

    Adri

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

    Re: Rename the File>Open dialog (Word 2003)

    Instead of using the wdDialogFileOpen dialog, you can use the FileDialog object introduced in Office 2002:
    <code>
    With Application.FileDialog(msoFileDialogFilePicker)
    .ButtonName = "New from Precedent"
    .Filters.Clear
    .Filters.Add "Word documents", "*.doc"
    .InitialFileName = LitTemplatePath & "*.doc"
    If .Show = True Then
    Set docNew = Documents.Add(Template:=.SelectedItems(1)
    End If
    End With
    </code>
    You can tweak this to your needs.

  3. #3
    Star Lounger
    Join Date
    Jun 2001
    Location
    Vancouver, Br. Columbia
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename the File>Open dialog (Word 2003)

    Thanks Hans...

    I have subfolders under LitTemplatePath and have both .doc and .dot files in the subfolders so I just want it to show all subfolders/files and they can then browse where they want.

    I will change the code if necessary, but is there a parameter I can just add to my existing code to change the dialog name?

    Adrienne

  4. #4
    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: Rename the File>Open dialog (Word 2003)

    > is there a parameter I can just add to my existing code to change the dialog name?

    No. To change the title bar on the Open dialog you likely would have to "hack" the dialog with the Windows API. Unless you have to support Windows 97-2000, it is much easier to use the FileDialogs collection.

  5. #5
    Star Lounger
    Join Date
    Jun 2001
    Location
    Vancouver, Br. Columbia
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rename the File>Open dialog (Word 2003)

    Ok, thanks for the info....I'll change the code as you suggest.

    Adri

  6. #6
    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: Rename the File>Open dialog (Word 2003)

    Here's an example specifying multiple file extensions:

    <code>Dim docNew As Word.Document, strExtensions As String, intCounter As Integer
    With Application.FileDialog(msoFileDialogFilePicker)
    ' Set up dialog title and file types selection for Word 2002-2007
    .Title = "New From Precedent"
    .ButtonName = "Create"
    .Filters.Clear
    strExtensions = "*.doc, *.dot" '2003
    'strExtensions = "*.doc, *.dot, *.docx, *.docm, *.dotx, *.dotm" '2007
    .Filters.Add "Word files", strExtensions, 1
    .FilterIndex = 1
    ' Open to desired initial folder
    .InitialFileName = LitTemplatePath
    .AllowMultiSelect = False ' one file only
    If .Show = -1 Then
    For intCounter = 1 To .SelectedItems.Count
    Set docNew = Documents.Add( _
    Template:=.SelectedItems(intCounter), _
    Visible:=True)
    docNew.Activate
    Set docNew = Nothing
    Next
    End If
    End With</code>
    Attached Images Attached Images

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

    Re: Rename the File>Open dialog (Word 2003)

    If you set AllowMultiSelect to False there's no point in looping through the SelectedItems array - only SelectedItems(1) will be available (since you already check whether Show returned -1, you know that the user selected a file).

  8. #8
    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: Rename the File>Open dialog (Word 2003)

    Hans, yes, that's true, but I thought I'd build it so it was easy to switch to multi-select = true. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

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

    Re: Rename the File>Open dialog (Word 2003)

    OK, good point! <img src=/S/grin.gif border=0 alt=grin 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
  •