Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Jul 2005
    Location
    Bangkok, Bangkok Metropolis, Thailand
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open workbook from VB (XP 2003)

    Dear all

    I have written VB code that attaches to a worksheet as a Macro with user entry userforms. When a teacher has completed a marksheet I want her to be able to exit the teacher entry form and return to the switchboard and then open a new workbook from there. Trouble is the location is unknown so I want the teacher to use a 'Windows Explorer' type interface and select the Excel marksheet to open. When the new marksheet opens it also needs to have the focus. All this from within the Switchboard.

    I have tried the eJExplorer component which looks OK, but I don't know how to use it. Any ideas please?

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

    Re: Open workbook from VB (XP 2003)

    The Application object in Excel VBA has a GetOpenFilename method that displays the standard open dialog. Use it like this:

    Dim fileToOpen As Variant
    Dim wbk As Workbook
    fileToOpen = Application.GetOpenFilename("Excel workbooks (*.xls), *.xls")
    If fileToOpen = False Then Exit Sub
    Set wbk = Workbooks.Open fileToOpen

Posting Permissions

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