Tags: allows, excel, figured, file, macro, microsoft, msdn, path, select, selected, software, specific, user, workbook, write

Macro To Open a User selected File

On Microsoft » Microsoft Excel

2,642 words with 2 Comments; publish: Fri, 23 May 2008 18:10:00 GMT; (30646.88, « »)

I need a macro that allows the user to select the file. I have figured out to

write a macro for specific path however, as this workbook will go to many

differnt users that will have differnt names and paths for the file. Any help

would be awsome. Thank in advance.

-CM

All Comments

Leave a comment...

  • 2 Comments
    • One way

      There is no code to test if the workbook is open in this example

      Sub test()

      Dim FName As Variant

      Dim wb As Workbook

      Dim MyPath As String

      Dim SaveDriveDir As String

      SaveDriveDir = CurDir

      MyPath = ThisWorkbook.Path

      ChDrive MyPath

      ChDir MyPath

      FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")

      If FName <> False Then

      Workbooks.Open (FName)

      End If

      ChDrive SaveDriveDir

      ChDir SaveDriveDir

      End Sub

      Regards Ron de Bruin

      http://www.rondebruin.nl/tips.htm

      "Chris" <Chris.excel.todaysummary.com.discussions.microsoft.com> wrote in message news:8CCD84AB-4542-47D9-84DA-1234BFC502C5.excel.todaysummary.com.microsoft.com...

      >I need a macro that allows the user to select the file. I have figured out to

      > write a macro for specific path however, as this workbook will go to many

      > differnt users that will have differnt names and paths for the file. Any help

      > would be awsome. Thank in advance.

      > -CM

      #1; Fri, 23 May 2008 18:11:00 GMT
    • Your A PRO!

      "Ron de Bruin" wrote:

      > One way

      > There is no code to test if the workbook is open in this example

      > Sub test()

      > Dim FName As Variant

      > Dim wb As Workbook

      > Dim MyPath As String

      > Dim SaveDriveDir As String

      > SaveDriveDir = CurDir

      > MyPath = ThisWorkbook.Path

      > ChDrive MyPath

      > ChDir MyPath

      > FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")

      > If FName <> False Then

      > Workbooks.Open (FName)

      > End If

      > ChDrive SaveDriveDir

      > ChDir SaveDriveDir

      > End Sub

      >

      > --

      > Regards Ron de Bruin

      > http://www.rondebruin.nl/tips.htm

      >

      > "Chris" <Chris.excel.todaysummary.com.discussions.microsoft.com> wrote in message news:8CCD84AB-4542-47D9-84DA-1234BFC502C5.excel.todaysummary.com.microsoft.com...

      > >I need a macro that allows the user to select the file. I have figured out to

      > > write a macro for specific path however, as this workbook will go to many

      > > differnt users that will have differnt names and paths for the file. Any help

      > > would be awsome. Thank in advance.

      > >

      > > -CM

      >

      #2; Fri, 23 May 2008 18:12:00 GMT