Results 1 to 3 of 3
  1. #1
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Dialog to open multiple files (Word 2002 SP-2)

    I'd like to be able to write Word macros that (1) display a file-chooser dialog that defaults to a designated directory and a designated filespec, (2) display the files sorted by name (without the user having to perform the sort), and (3) allow the selection of multiple files.

    I know about the goofy CommandBars.FindControl(ID:=23, Visible:=False).Execute workaround, but (1) it doesn't let you specify a filespec, and (2) it doesn't work if the macro with the CommandBars line is called by a 2nd macro using Application.Run or Dialogs(wdDialogToolsMacro).Execute -- and those are the only options I know of if the macro being called is in a string that's been passed or inputted to the calling macro.

    I thought my prayers had been answered when I found this MSDN Library article: Enhance Your Apps with Common Dialogs: Part I. It wraps the API stuff for the Windows Common Dialog in a class module and includes a gratifying handful of input arguments. Unfortunately, though, the files are displayed unsorted, forcing the user to right-click and Arrange By Name to get the files in alphabetical order.

    The same article also mentions a Common Dialog ActiveX Control (COMDLG32.OCX), which might meet my requirements but, alas, we lowly Office Pro owners don't have that control.

    Anybody know of a total solution?

    <img src=/S/ranton.gif border=0 alt=ranton width=66 height=37> It is beyond pathetic, is it not, that Word 2002 doesn't offer simple, easy VBA access to a file-chooser dialog with the ability to designate an initial filespec and select multiple files? <img src=/S/rantoff.gif border=0 alt=rantoff width=66 height=37>

  2. #2
    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: Dialog to open multiple files (Word 2002 SP-2)

    Want some really slow, old code that uses the FileSearch object? <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15> That's all I can offer at the moment. See <post#=58427>post 58427</post#>.

  3. #3
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Dialog to open multiple files (Word 2002 SP-2)

    Thanks for the code. It turns out the initial sorting of the Common Dialog is determined by Explorer's default folder setting (i.e., the sort that was in effect the last time you took a deep breath and hit the "Apply to All Folders" button under Folder Options-->View). For some reason I had unintentionally set that to a sort other than By Name (By Type, I think). Now that's fixed and the Common Dialogs my Word macros are calling (by way of the class module I referred to in my first post) are sorted by name (and accepting filespecs and allowing multiple files to be opened, my desired trifecta).

    As soon as I'm finished resetting the blown-out remembered settings in all my Explorer folders, I'll be fine.

Posting Permissions

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