Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change FileOpen Type (Word 2000)

    The following snippet displays a FileOpen Dialog box with a filter set to RTF.

    <pre> Set mydlg = Dialogs(wdDialogFileOpen)
    mydlg.Name = "*.rtf"
    If mydlg.Show <> 0 Then
    'Do Stuff
    End If
    </pre>


    However, it doen't change the selection at the bottom of the dialog for "Files of Type."

    Wondering if there is a way to change the Files of Type setting -- to show only Word Documents or Only RTF files.

    Thanks

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    <pre> With Dialogs(wdDialogFileOpen)
    .Name = "*.rtf"
    If .Display = -1 Then
    Debug.Print "Do whatever"
    Else
    Debug.Print "Do something else"
    End If
    End With
    </pre>


  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    The question isn't how to filter on RTF - my version with .Show does the same and also has the trap for cancellation.

    The question is how to modify the "Files of Type" drop down instead of (or in addition to) the Name property.

    Right now both your solution and mine show only RTF files, but the Type drop down shows whatever was the last type used by FileOpen.

  4. #4
    Star Lounger
    Join Date
    Jun 2002
    Posts
    98
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    mydlg.Format = "Rich Text Format (*.rtf)"

    ...worked for me once. And I mean ONCE. At least it shows the right files. Doesn't always change the text displayed in the File Type field of the dialog however. Frustrating.

    You can get a list of the built-in dialog properties (Name, Format, etc...) in the online VBA help.
    __________________________________________________ ____
    <img src=/S/nun.gif border=0 alt=nun width=20 height=20> Sister Dory
    Our Lady of Perpetual Help, Holstein Falls, Wisconsin, USA

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    >>...worked for me once. And I mean ONCE.

    Better than I did. Didn't work at all.

    The help file lists the arguments for wdFileOpen, but I couldn't find a place that describe the Format argument.

    It's a minor annoyance. The .name = "*.rtf" does filter for RTF, but since this is for public consumption I find it potentially confusing for users that the lists should display only RTF files and the decription of "Files of Type" would show "All Word Documents (*.DOC etcetc).

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

    Re: Change FileOpen Type (Word 2000)

    In Word 97, the following works:

    With Dialogs(wdDialogFileOpen)
    .Name = "*.rtf"
    .Format = wdOpenFormatRTF
    If .Show <> 0 Then
    ' Whatever
    End If
    End With

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    I understood your question as the files of type box not being set to RTF.

    Try using SEndKeys to modify the files of type box.

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    >>In Word 97, the following works:

    Thanks Hans. It doesn't seem to have any effect in Word 2000.

    curiously, if you had an .Update after the .Format, it seems to negate the effect of .Name = "*.RTF" and the list is no longer filtered.

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    >>Try using SEndKeys to modify the files of type box.

    Good ole SendKeys. Yes, it will set the Files Of Type box "manually," but the problem is, there's no way to set it BACK.

    The Word Object model was supposed to fix the shortcomings of WordBasics Dim dlg as FileOpen, not lose functionality.

    In theory I should be able to do a

    holder = .Format
    .Format = wdOpenRTF
    .Show

    to display only RTF and then

    .Format =holder
    .Execute

    to set it back to whatever was the case at the start of the procedure.

    Another bug... er...feature...

  10. #10
    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: Change FileOpen Type (Word 2000)

    This has been bemoaned before here in the Lounge. Combing the object browser yielded a solution:
    <pre>Options.DefaultOpenFormat = wdOpenFormatRTF
    With Dialogs(wdDialogFileOpen)
    If .Display = -1 Then
    .Execute
    End If
    End With
    Options.DefaultOpenFormat = wdOpenFormatAllWord</pre>

    Last line can be whatever user's prior setting was, if you don't want to minimize the mucking of defaults.

  11. #11
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    New York
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change FileOpen Type (Word 2000)

    Precisely what I wanted. Thanks.

Posting Permissions

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