Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    Toronto, Ontario, Canada
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open Dialog Box (2003)

    If I wanted to open another Excel spreadsheet using a command button on a user form, what is the code I would use? (in the cmdButton_Click subroutine)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Open Dialog Box (2003)

    Private Sub cmdButton_Click()
    Dim fileToOpen As Variant
    Dim wbk As Workbook
    fileToOpen = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
    If Not fileToOpen = False Then
    Set wbk = Workbooks.Open(fileToOpen)
    ' do things with wbk here
    ...
    End If
    End Sub

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Dialog Box (2003)

    Your question said that you wanted to open another "spreadsheet". Hans' code shows you how to open another WORKBOOK. Is that what you really meant, or did you really mean worksheet? If you meant worksheet, then do you want to "open" (select) one that already exists in the workbook, or do you want to add a new sheet to the workbook?
    Legare Coleman

  4. #4
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    Toronto, Ontario, Canada
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Open Dialog Box (2003)

    Sorry - bad terminology - I meant workbook.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •