We help IT Professionals succeed at work.

Excel VBA output file path

ho_alan
ho_alan asked
on
3,283 Views
Last Modified: 2012-06-27
I have to output a text in VBA

    Path = "c:\temp\result.txt"
    lineout = FreeFile
    Open Path For Output As #lineout
    Print #lineout, result
    Close #lineout


i don't want to have a fixed path
so tha the text file can just be saved under the same folder as the workbook

i have tried Path = ".\result.txt"
but it doesn't work

what should the path?

thanks a lot!!!
Comment
Watch Question

Brian MulderFreelance
Top Expert 2006

Commented:
you could try

ThisWorkbook.Path

or

Application.Path

but i think thisworkbook is the prefered way

hope this helps a bit
Freelance
Top Expert 2006
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thanks a lot!!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*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.