Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working in Excel for Mac 2011 and my goal is to create a simple macro that writes particular cells to a file. This is generally a simple task, but VB chooses not to accept a file path. For example, the following code literally writes a file called ~/file.txt, ignoring the directory structure entirely:

Open "~/file.txt" For Output As #1

I have tried the full path /Users/Sergey/file.txt to no avail.

share|improve this question

You have to retrace the path back to the hard disk. If I run

Open "testfile.txt" For Output As 1

the new file appears in /Applications/Microsoft Office 2004/Templates/

If I retrace back to the hard disk with

Open "..:..:..:Users:henrywhitney:Documents:Scribe:Macro Data:testfile.txt" For Output As 1

it appears in /Users/henrywhitney/Documents/Scribe/Macro Data/.

share|improve this answer
Henry - thank you so much - I had been struggling with this problem for hours, and it now works. You've made my day! – FarmerGedden Apr 12 '12 at 9:25

Did you try to use : instead of /? Something like


You can also try:

ThisWorkBook.Path & Application.PathSeparator & "file.txt"
share|improve this answer
The former came up with an error: "Path not found." The latter worked out fine, however working relative to the excel document is not always the ideal scenario. For my purpose here, it did the job. – Sergey Jul 9 '11 at 4:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.