Dragon Drop - A Visual Basic Software Consultancy

Word Tips

File Open Dialog Box

If one is required to display a File Open dialog box then the documentation shows you something like this:

Dialogs(wdDialogFileOpen).Show

However, there is one rather large problem. This is that if the user decides to select more than one file then nothing happens. This is a known bug within Word 97 and 2000 (I haven't tested this code with other versions of Word).

There is a workaround; this is to directly execute the control button for File Open itself. This causes the dialog to appear and to work normally. There is one caveat if one has a Document Management System (DMS) running which uses ODMA then this won't work as instead of the native dialog box appearing the DMS's own File Open dialog will appear.

Sub OpenDialogBox()

  Dim objCommandBarControl As CommandBarControl
  
  
  On Error Resume Next
  
  Set objCommandBarControl = CommandBars.FindControl(ID:=23)
  If Not objCommandBarControl Is Nothing Then
    objCommandBarControl.Execute
    Set objCommandBarControl = Nothing
  End If

End Sub

Thanks to Tim Rylatt for putting me onto this.

Updates

If there are any suggestions for updates then please drop me a mail at malcolm.smith@dragondrop.com.