+ Reply to Thread
Results 1 to 6 of 6

Browse for file name code? (Excel 2002 VBA)

  1. #1

    Browse for file name code? (Excel 2002 VBA)

    Hello. I need to create a macro that displays a browser window, lets
    the user choose a folder and then a filename within the folder, and
    updates all the links in the file to that found file. I wrote the code
    that updates the links but I am struggling creating code that lets the
    user choose the folder and filename. Searching around I found the
    following code. It works wonderfully allowing the user to select a
    folder. But how do I make it display the filenames within a folder and
    let the user select one? Thanks for any help!
    http://www.cpearson.com/excel/BrowseFolder.htm


  2. #2
    AA2e72E
    Guest

    RE: Browse for file name code? (Excel 2002 VBA)

    application.Dialogs(xlDialogFindFile).Show
    might be what you need.

    "[email protected]" wrote:

    > Hello. I need to create a macro that displays a browser window, lets
    > the user choose a folder and then a filename within the folder, and
    > updates all the links in the file to that found file. I wrote the code
    > that updates the links but I am struggling creating code that lets the
    > user choose the folder and filename. Searching around I found the
    > following code. It works wonderfully allowing the user to select a
    > folder. But how do I make it display the filenames within a folder and
    > let the user select one? Thanks for any help!
    > http://www.cpearson.com/excel/BrowseFolder.htm
    >
    >


  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    try

    Dim sFile As String
    sFile$ = Application.GetOpenFilename

    you will still to add code to open the file

    for save as try

    sFile$ = Application.GetSaveAsFilename

  4. #4
    Doug Glancy
    Guest

    Re: Browse for file name code? (Excel 2002 VBA)

    One more option, available I think only in 2002 and later. It lets you set
    an initial file:

    Sub test()
    Dim file_dialog As FileDialog

    Set file_dialog = Application.FileDialog(msoFileDialogOpen)
    With file_dialog
    .AllowMultiSelect = False
    .Title = "Pick a File to Link to if You Dare"
    .ButtonName = "Link"
    .InitialFileName = "C:\Documents and Settings\Doug\My Documents"
    .Show
    If .SelectedItems.Count = 1 Then
    MsgBox .SelectedItems(1)
    End If
    End With
    End Sub


    --
    Doug


    <[email protected]> wrote in message
    news:[email protected]...
    > Hello. I need to create a macro that displays a browser window, lets
    > the user choose a folder and then a filename within the folder, and
    > updates all the links in the file to that found file. I wrote the code
    > that updates the links but I am struggling creating code that lets the
    > user choose the folder and filename. Searching around I found the
    > following code. It works wonderfully allowing the user to select a
    > folder. But how do I make it display the filenames within a folder and
    > let the user select one? Thanks for any help!
    > http://www.cpearson.com/excel/BrowseFolder.htm
    >




  5. #5

    Re: Browse for file name code? (Excel 2002 VBA)

    Thanks for the ideas, but I searched a little more and found
    Application.FileDialog to use instead of all that code. It's exactly
    what I need.


  6. #6
    Tom Ogilvy
    Guest

    Re: Browse for file name code? (Excel 2002 VBA)

    As long as you recognize that application.filedialog only works in xl2002 and
    later.



    --
    Regards,
    Tom Ogilvy


    "[email protected]" wrote:

    > Thanks for the ideas, but I searched a little more and found
    > Application.FileDialog to use instead of all that code. It's exactly
    > what I need.
    >
    >


+ 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