Opening multiple files error

A

Alfred

Since many years I use the following macro that suits my needs:

Sub FileOpen ( )
SendKeys “+({TAB})”
Dialogs(wdDialogFileOpen).Application.Caption = " "
Dialogs (wdDialogFileOpen). Show
On Error Resume Next
ActiveDocument.ActiveWindow.Caption = _
ActiveDocument.ActiveWindow.Caption +
" "
End Sub

The FileOpen Dialog has one setback, however: it does not allow to
open multiple files at once (error 5174, file cannot be found)
Opening multiple files using a right click also gives an error (there
is another active dialog running)
According to the Microsoft webpages this behavior is by default.
I found two work-arounds or solutions that I cannot get to work.

The first workaround is :
CommandBars.FindControl(ID:=23, Visible:=False).Execute
instead of:
Dialogs(wdDialogFileOpen)

I tried it, but it gave an error.

The second one is (from Microsoft):

This example displays the Open dialog box and allows a user to select
multiple files to open.
Sub ShowFileDialog()
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog( _
FileDialogType:=msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = True
.Show
End With
End Sub

I tried this macro, but it gives a VB ‘compiling error’

What I want is to use my original code (without extra message boxes,
toolbars or buttons), but to keep the ability of opening multiple
files at once.
I use Windows XP, Word 2003 and VB6.
Anyone can help?

Thanks,
Alfred
 
C

Cindy M.

Hi Alfred,

Your question would be better asked in the word.programming or
word.vba.general newsgroup, where you'd find more people who deal with
code.

The code snippet (below) that causes the error:

- which line triggers the error?

- Are you running this from VB6 or from VBA? If VB6, Application will
not refer to the Word application, but your VB6 application, which
would explain the error...
This example displays the Open dialog box and allows a user to select
multiple files to open.
Sub ShowFileDialog()
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog(
FileDialogType:=msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = True
.Show
End With
End Sub

I tried this macro, but it gives a VB ‘compiling error’

What I want is to use my original code (without extra message boxes,
toolbars or buttons), but to keep the ability of opening multiple
files at once.
I use Windows XP, Word 2003 and VB6.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top