We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

One line of code...need help

bctek
bctek asked
on
Medium Priority
180 Views
Last Modified: 2010-05-01
I keep getting an error that the file cannot be found:

Excel.Workbooks.Open("fake_users.xls")

yet fake_users.xls exists right in my BIN directory.  How do I get it to open this worksheet with a relative path to the EXE?
Comment
Watch Question

Try specifying the full path

Excel.Workbooks.Open("c:\myfolder\fake_users.xls")

Author

Commented:
i dont want the full path, i want a relative path to the EXE.

Author

Commented:
ERROR returned:  "Additional information: 'fake_users.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct."
This is a relative directory that equals the current if this is what you mean
Excel.Workbooks.Open(".\fake_users.xls")
or if the bin directory is under your current then
Excel.Workbooks.Open(".\bin\fake_users.xls")
or app.path will look in the current directory like so
Excel.Workbooks.Open(app.path & "\fake_users.xls")

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
still doesn't work :(
same error returned.
" '.\fake_users.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct."

the file exists right next to the .exe
If I put the absolute path in, it works fine, but can't get it to open relatively
Can you paste the full path of where the file is

Author

Commented:
the app.path worked.   ALl set now!  Thanks
Good, sorry I misread the question at first. Have a pleasant evening
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.