Announcement

Collapse
No announcement yet.

Macro: Allow User to Choose Workbook/File to Open

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

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

    try this


    Sub openIt()
    Dim strFile As String

    strFile = Application.GetOpenFilename
    Workbooks.Open strFile
    End Sub

    Kind Regards, Will Riley

    LinkedIn: Will Riley

    Comment


    • #3
      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, 13:04.
      Boo!

      Comment


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

        That Worked Beautifully. Thanks for you help.

        Comment


        • #5
          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
          Code:
          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, 05:48.
          Get custom programming done at GetAFreelancer.com!

          Comment

          Working...
          X