Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

One line of code...need help

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?
0
bctek
Asked:
bctek
  • 4
  • 4
1 Solution
 
ComputronCommented:
Try specifying the full path

Excel.Workbooks.Open("c:\myfolder\fake_users.xls")
0
 
bctekAuthor Commented:
i dont want the full path, i want a relative path to the EXE.
0
 
bctekAuthor 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."
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ComputronCommented:
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")
0
 
bctekAuthor 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
0
 
ComputronCommented:
Can you paste the full path of where the file is
0
 
bctekAuthor Commented:
the app.path worked.   ALl set now!  Thanks
0
 
ComputronCommented:
Good, sorry I misread the question at first. Have a pleasant evening
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now