+ Reply to Thread
Results 1 to 2 of 2

Application.FileDialog(msoFileDialogOpen)

  1. #1
    Registered User
    Join Date
    01-20-2006
    Posts
    19

    Application.FileDialog(msoFileDialogOpen)

    LS,

    from Excel with VBA using a UserForm I can display the files in a special directory, using:

    With Application.FileDialog(msoFileDialogOpen)
    .InitialFileName = strPath & "\*"
    .AllowMultiSelect = False
    .Show
    End With

    How do I manage that from that FileDiaolog a file (.xls, .doc or .txt) can be opened?

    Doubleclick on the file gives no result.

  2. #2
    Ron de Bruin
    Guest

    Re: Application.FileDialog(msoFileDialogOpen)

    This example use GetOpenFilename that can do the same and it is working in 97 and up

    Sub test()
    Dim FName As Variant
    Dim wb As Workbook
    Dim MyPath As String
    Dim SaveDriveDir As String

    SaveDriveDir = CurDir

    MyPath = ThisWorkbook.Path
    ChDrive MyPath
    ChDir MyPath

    FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
    If FName <> False Then
    Set wb = Workbooks.Open(FName)
    MsgBox "your code"
    wb.Close
    End If

    ChDrive SaveDriveDir
    ChDir SaveDriveDir

    End Sub


    For multiselect do it like this

    Sub testing()
    Dim FName As Variant
    Dim N As Long
    FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", _
    MultiSelect:=True)

    If IsArray(FName) Then
    For N = LBound(FName) To UBound(FName)
    Workbooks.Open (FName(N))
    Next
    End If
    End Sub


    --
    Regards Ron De Bruin
    http://www.rondebruin.nl



    "H.A. de Wilde" <[email protected]> wrote in message
    news:[email protected]...
    >
    > LS,
    >
    > from Excel with VBA using a UserForm I can display the files in a
    > special directory, using:
    >
    > With Application.FileDialog(msoFileDialogOpen)
    > InitialFileName = strPath & "\*"
    > AllowMultiSelect = False
    > Show
    > End With
    >
    > How do I manage that from that FileDiaolog a file (.xls, .doc or .txt)
    > can be opened?
    >
    > Doubleclick on the file gives no result.
    >
    >
    > --
    > H.A. de Wilde
    > ------------------------------------------------------------------------
    > H.A. de Wilde's Profile: http://www.excelforum.com/member.php...o&userid=30679
    > View this thread: http://www.excelforum.com/showthread...hreadid=548160
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1