LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Cannot open file for output

Hi

I am trying to run some very simple code to write to a file on my host PC
using an Excel VBA macro:

Sub TestFileOpening()
Dim FileNumber As Integer
FileNumber = FreeFile()
Open "C:\TEST.TXT" For Output As #FileNumber
Write #FileNumber, "This is a sample."
Close #FileNumber
End Sub

The 'write' statement fails with 'Run-time error '54' Bad file mode'.

This code runs fine on a colleague's machine. I have tried setting the Excel
security level to medium or low but still get the error. I think the code is
correct so I suspect a security issue but I don't know where else to look.

I am running Excel 2003 SP1 on Windows XP Prof SP2.

Can anyone help me please?

David



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open a print output sent to file Ted Johnston Excel Discussion (Misc queries) 0 February 24th 06 10:10 AM
CSV output file Suzanne[_5_] Excel Programming 2 March 4th 05 05:03 PM
VBA help to output a file Paula Weill Excel Programming 2 September 20th 04 02:12 PM
"Unable to Open File" - excel output of Datagrid <-help needed Steve Chatham[_2_] Excel Programming 0 February 25th 04 07:59 PM
Diff. btw Open [path] For OUTPUT vs. For INPUT XLDweeb Excel Programming 0 November 18th 03 11:14 AM


All times are GMT +1. The time now is 12:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"