+ Reply to Thread
Results 1 to 3 of 3

Macro which opens Browse window and pastes the file name to a cell ?

  1. #1
    Registered User
    Join Date
    11-26-2012
    Location
    finland
    MS-Off Ver
    Excel 2003
    Posts
    2

    Macro which opens Browse window and pastes the file name to a cell ?

    Hello,

    I'm trying to find a macro which could do following.

    When running the macro it would open the browse window where I could choose what ever file (it can be *.pdf, *.doc, *.txt, etc) and it would just bring the file name to the Excel cell which was active before running the macro.

    Any help appriciated.

    Keimoon

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro which opens Browse window and pastes the file name to a cell ?

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    11-26-2012
    Location
    finland
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Macro which opens Browse window and pastes the file name to a cell ?

    Hello,

    This is almost what I'm trying to accomplish, but it should be just filename like general.doc which should be "pasted" to active cell (no path). File extension can be "what ever". I made some changes to the code but couple of things missing :

    -How to send the filename to the cell where cursor is (if I activate cell A5 and run the Macro it should paste the filename without the path to this cell)

    ****************************
    Sub Opendialog9()
    Dim strFile As String, strPath As String

    ' Prompt user to select a file
    With Application.FileDialog(msoFileDialogOpen)
    .InitialFileName = ThisWorkbook.Path & "\*.*" (I changed *.xls* with *.* to allow all exten)
    .Title = "Please Select a File"
    .AllowMultiSelect = False
    .Show
    If .SelectedItems.Count = 0 Then Exit Sub ' User clicked cancel: Exit
    strFile = .SelectedItems(1)
    End With
    Range("B2") = strFile (how could this Range to be changed so that the input cell is which is active before running the Macro?)
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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