Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Bad File name or number

I had a small subroutine where I read one text file and wrote to another. It
worked fine, but then I wanted to break the write (Print statement) out
various subroutines. Now I am receiving error:
Run-Time error '52':
Bad File name or number

Any thoughts on how to acomplish this? I want to open the input and output
files in the main sub, and then read/write in various sub-routines.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Bad File name or number


without seeing your code it's hard to give a specific answer

If you use commands like this
Print #1, "This is a test" ' Print text to file.

you probally need a glabal variable to hold your free file number and
then use that variable within each sub routine

use this to get a free file numer
dim iFF as integer
iFF = FreeFile

then use variable in command
Print #myVariable, "This is a test" ' Print text to file.
*-Post posted before response, posts merged!*-
Oops typo in my previos reply
Print #myVariable, "This is a test" ' Print text to file.

should be
Print #iFF, "This is a test" ' Print text to file.


--
mudraker

If my reply has assisted or failed to assist you I welcome your
Feedback.

www.thecodecage.com
------------------------------------------------------------------------
mudraker's Profile: http://www.thecodecage.com/forumz/member.php?userid=18
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=27096

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Bad File name or number

You would think I would know better. I sat here trying to execute just the
subroutine instead of the main sub. It is working correctly.

Thanks for the qucik response though!
Reply
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
Number Format on Excel File saved from .html file joyfulone Excel Discussion (Misc queries) 3 April 15th 09 12:07 AM
How to tell number of spaces between values in saved text file fromthe original xls file [email protected] Excel Discussion (Misc queries) 1 January 15th 08 11:52 AM
Count Number of Records and Number of Fields in CSV File ExcelMonkey Excel Programming 0 November 29th 07 10:58 PM
Open Test file with VBA with a changing file number Michael from Austin Excel Programming 4 October 14th 05 03:18 PM
Create a batch file from a number of Excel File Vinay[_2_] Excel Programming 0 September 8th 04 01:11 AM


All times are GMT +1. The time now is 02:18 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"