+ Reply to Thread
Results 1 to 4 of 4

Code for bring up the file->open dialog box

  1. #1
    Ben
    Guest

    Code for bring up the file->open dialog box

    Hi all,

    Please share with me the code to simulate the File->Open dialog box in
    VBA. Thanks so much.

    Ben

    --


  2. #2
    Brian
    Guest

    Re: Code for bring up the file->open dialog box

    this might be of use, its from the post about how to parse a text file ....
    it has a open file (incl a filter for text files!), you should be able to
    strip out the useful bits...

    Brian

    >Tom Ogilvy wrote:
    >
    > Sub testme2()
    > Dim FName As String
    > Dim FNum As Long
    > Dim sLine As String
    > Dim TName As Variant
    >
    > TName = Application.GetOpenFilename _
    > (fileFilter:="Text Files (*.txt),*.txt,All Files (*.*),*.*", _
    > Title:="Open Report")
    > If TName = False Then
    > MsgBox "You didn't select a file"
    > 'Exit Sub
    > Cleanup
    > End
    > End If
    >
    > FName = CStr(TName)
    >
    > FNum = FreeFile
    >
    > Open FName For Input As FNum
    > Do While Not EOF(FNum)
    > Input #FNum, sLine
    > If InStr(1, sLine, "NUE00001 GRAND TOTALS", _
    > vbTextCompare) > 0 Then
    > Line Input #FNum, sLine 'Match where next line is needed
    > Cells(3, 3).Value = sLine
    > ElseIf InStr(1, sLine, "NUE00002 GRAND TOTALS", _
    > vbTextCompare) > 0 Then
    > Line Input #FNum, sLine
    > Line Input #FNum, sLine 'Match where line 2 down is needed
    > Cells(4, 3).Value = sLine
    > End If
    > Loop
    > ' now close the file
    > Close #FNum
    > End Sub

    "Ben" <Ben@discussions.microsoft.com> wrote in message
    news:5BEF1AFF-A252-4FE8-80BF-88B48F5FE820@microsoft.com...
    > Hi all,
    >
    > Please share with me the code to simulate the File->Open dialog box in
    > VBA. Thanks so much.
    >
    > Ben
    >
    > --
    >




  3. #3
    Norman Jones
    Guest

    Re: Code for bring up the file->open dialog box

    Hi Ben,

    Try:

    Application.Dialogs(xlDialogOpen).Show


    ---
    Regards,
    Norman


    "Ben" <Ben@discussions.microsoft.com> wrote in message
    news:5BEF1AFF-A252-4FE8-80BF-88B48F5FE820@microsoft.com...
    > Hi all,
    >
    > Please share with me the code to simulate the File->Open dialog box in
    > VBA. Thanks so much.
    >
    > Ben
    >
    > --
    >




  4. #4
    Ben
    Guest

    RE: Code for bring up the file->open dialog box

    Thank you Brian and Norman.

    Ben

    --



    "Ben" wrote:

    > Hi all,
    >
    > Please share with me the code to simulate the File->Open dialog box in
    > VBA. Thanks so much.
    >
    > Ben
    >
    > --
    >


+ 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