Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 5 of 5

Thread: Macro: Allow User to Choose Workbook/File to Open

  1. #1
    Join Date
    8th September 2006
    Posts
    6

    Macro: Allow User to Choose Workbook/File to Open

    I am making a macro that requires that user to enter a directory path into a input box and the macro will open the file. Right now it works fine bit i would like to change the code so that instead of using an input box it brings up a box that will allow them to browse files on their computer and then select one to open. Does anyone know how i can do this.

    Thanks
    Nick

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    28th January 2003
    Location
    Solihull - England
    Posts
    8,676

    Re: Making a Macro That has the User Select a file to open and opens it

    try this

    VB:
    Sub openIt() 
        Dim strFile As String 
         
        strFile = Application.GetOpenFilename 
        Workbooks.Open strFile 
    End Sub 
    
    
    Kind Regards, Will Riley

    Web Presence:
    Personal: The Trouble With Data
    LinkedIn: Will Riley

  3. #3
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Making a Macro That has the User Select a file to open and opens it

    Nick

    Use Application.GetOpenFilename.

    You'll find more information on the syntax in help, but post back here if you need further help.
    Last edited by Dave Hawley; September 8th, 2006 at 13:04.

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    8th September 2006
    Posts
    6

    Re: Making a Macro That has the User Select a file to open and opens it

    That Worked Beautifully. Thanks for you help.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    20th July 2006
    Posts
    50

    Re: Making a Macro That has the User Select a file to open and opens it

    Dont forget to check if user doesnt cancel the operation.
    In that case this method will return False value.

    Something like this
    VB:
    Sub openIt() 
        Dim strFile As String 
         
        strFile = Application.GetOpenFilename 
        If strFile <> "False" Then Workbooks.Open strFile 
    End Sub 
    
    
    Last edited by Thor; September 8th, 2006 at 05:48.

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Allow User To Choose Folder/File To Open
    By jamiwr in forum EXCEL HELP
    Replies: 6
    Last Post: April 18th, 2008, 09:23
  2. Replies: 4
    Last Post: March 6th, 2008, 04:00
  3. Allow User To Choose File To Open
    By Tomaff01 in forum EXCEL HELP
    Replies: 2
    Last Post: February 7th, 2008, 18:36
  4. Allow User To Choose File to Open
    By tsuimark in forum EXCEL HELP
    Replies: 3
    Last Post: October 20th, 2006, 09:03
  5. Let Users Choose File/Workbook to Open
    By Jwesterlund in forum EXCEL HELP
    Replies: 4
    Last Post: October 20th, 2006, 05:04

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
  •  
porno