• Change FileOpen Type (Word 2000)

    Author
    Topic
    #372736

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

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

    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

    Viewing 1 reply thread
    Author
    Replies
    • #596782
          With Dialogs(wdDialogFileOpen)
              .Name = "*.rtf"
              If .Display = -1 Then
                  Debug.Print "Do whatever"
              Else
                  Debug.Print "Do something else"
              End If
          End With
      
      • #596784

        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.

        • #596856

          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.

          • #596930

            >>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…

            • #597420

              This has been bemoaned before here in the Lounge. Combing the object browser yielded a solution:

              Options.DefaultOpenFormat = wdOpenFormatRTF
              With Dialogs(wdDialogFileOpen)
                  If .Display = -1 Then
                      .Execute
                  End If
              End With
              Options.DefaultOpenFormat = wdOpenFormatAllWord

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

            • #597425

              Precisely what I wanted. Thanks.

    • #596788

      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.

      • #596793

        >>…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).

        • #596802

          In Word 97, the following works:

          With Dialogs(wdDialogFileOpen)
          .Name = “*.rtf”
          .Format = wdOpenFormatRTF
          If .Show 0 Then
          ‘ Whatever
          End If
          End With

          • #596897

            >>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.

    Viewing 1 reply thread
    Reply To: Change FileOpen Type (Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: