Results 1 to 2 of 2

Thread: File opening, simple question please

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    I need to open file in my apps directory, like the following:
    Code:
    Set wbkWorkbook = objExcel.Workbooks.Open(App.Path & "\" & "Orders.xls")
    Problem is that if the file is in ROOT directory, I'll get an error
    because of the slash between App.Path & the "Orders.xls".
    How can I test if my file is in the root directory or not, and what's
    the correct syntax for fixing this problem.
    Thanks

    Tomexx.

  2. #2
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Talking

    Code:
    If right(app.path,1) = "/" then
         Set wbkWorkbook = objExcel.Workbooks.Open(App.Path & "Orders.xls")
    else
         Set wbkWorkbook = objExcel.Workbooks.Open(App.Path & "\" & "Orders.xls")
    End If
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

Posting Permissions

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



Click Here to Expand Forum to Full Width