Results 1 to 9 of 9
  1. #1
    JustCallMeAl
    Guest

    All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    Please refer to the following article: <A target="_blank" HREF=http://www.mvps.org/word/FAQs/MacrosVBA/OpenMultipleFiles.htm>Calling FileOpen dialog in VBA does not allow opening of multiple files</A>.

    Using the VBA line of:

    <pre>CommandBars.FindControl(ID:=23, Visible:=False).Execute </pre>


    I would like the dialog box to show all files (*.*) instead of the last "File of Type."

    In other words, if the File Open dialog box had shown only Word Documents (*.doc), I would like it to be automatically changed to All Files (*.*) AND use the above VBA code. I have tried different variations of using the Dialogs(wdDialogFileOpen), but nothing seems to work.

    This would allow our users to open multiple files. The catch is that we would need to change the File of Type to All Files (*.*).

    Suggestions?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    Al,

    My experience shows that no argument will change the Files of Type field on the Open dialog. I thought I had some success with

    .format = " *** various syntactical inventions *** ", but nothing worked.

    I believe that setting is stored in the registry in binary form under the previously extensively mentioned Data key.

    I have noticed that if a user manually changes the setting, the setting becomes the default for that user.

    By the way, how are you getting multiple files to open using this technique? Popping up the Save dialog via it's control ID does not work for me.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    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: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    If you can't change it, you can at least override it. Yeah, it's hard to understand why you are seeing HTML files when it says Word Documents, but... it works:

    <pre>ChangeFileOpenDirectory "c:"
    With Dialogs(wdDialogFileOpen)
    .Name = "*.htm*"
    If .Display <> -1 Then Exit Sub
    'grab the file name before without opening
    strFileName = .Name
    End With</pre>

    I do not try to select multiple files this way. I cannot open multiple files using the dialog interactively, so I am not surprised it does not work in VBA. I'm running 2000, so YMMV.

  4. #4
    JustCallMeAl
    Guest

    Re: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    About your question at the bottom, I'm not using the Save dialog. I'm using the file open dialog. Run CommandBars.FindControl(ID:=23, Visible:=False).Execute in the immediate window, and you will get the file open dialog box.

    To see about opening multiple files to open, see the link in the original message. It gives the code for that very purpose.

  5. #5
    JustCallMeAl
    Guest

    Re: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    There are two criteria: (1) Override whatever file type with *.* (All Files) and (2) select multiple files. Each can be done individually. But can they be done in conjunction? From what I have personally found out, no.

    Kevin says No.

    So we will have to see if there is or not.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    Yes, indeed, I meant Open not SaveAs. Slip of the tongue.

    The reason I asked about how you are doing this is I get the error message below using this technique.
    Attached Images Attached Images
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    JustCallMeAl
    Guest

    Re: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    Is this with using the macro from the link? It worked okay for me. [img]/forums/images/smilies/sad.gif[/img]

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    Yes. I didn't include the "these files are open" bit, 'cause that's not necessary, but the execute on the commandbar control is the key.

    I think what happens is since I have trapped the FileOpen sub, the executing of control ID 23 simply invokes that "macro" which is all coded up to provide some custom functionality.

    I need to .Display the dialog before .executing. The "control executing" technique can't do that.

    Here's a sample:

    Set dlg = Dialogs(wdDialogFileOpen)
    With dlg
    Select Case .Display
    Case -1 'Ok Open
    aFolderName = Options.DefaultFilePath(wdDocumentsPath)
    aFileName = .Name
    If InStr(aFileName, " ") <> 0 Then 'Filename has spaces
    aFileName = Mid$(.Name, 2, Len(.Name) - 2)
    End If
    'Name returns in quotes because of spaces in name
    aFileExt = ExtractString(aFileName, 2, ".")
    Select Case UCase(aFileExt)
    Case "DOC", "DOT"
    'Assume a document with writepassword
    .WritePasswordDoc = "PasswordProtect" 'These two lines are only to insure old docs will open
    .WritePasswordDot = "PasswordProtect"
    'Reset attributes for Library files on open so Macro group and edit them
    If UCase(aFolderName) Like "*PERB TEMPLATES*" Then
    SetAttr aFolderName + "" + aFileName, vbNormal
    End If

    On Error Resume Next 'Must account for user selecting more than one file. Word does not allow this in open dialog
    .Execute
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  9. #9
    renevargas1
    Guest

    Re: All Files in FileOpen Dialog Box (VBA/Word97 SR2)

    One question... I have tested the VBA line in the article you mentioned and it works... MOST of the time. The big exception occurs if I change the name of the macro to read "FileOpen" (to intercept the default FileOpen in Word). I then get an error message (see attached file) and also an "out of stack" message. Could you please tell me what is going on?

    Thanks,

    Rene

Posting Permissions

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