View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Passing parameters between functions

Dim fnum as Integer
fnum = freefile
Open "test.txt" For Output As #fnum
'some code
Write #fnum, "This is some test data"
mySpecialFunction fnum
'more code
Close #fnum



Sub myspecialfunction( fnum as integer)

Write #fnum, "this is another line

End Sub

---- from help on freefile - - - -

Returns an Integer representing the next file number available for use by
the Open statement.

--
Regards,
Tom Ogilvy


Gaston wrote in message
...
I'm trying to do a macro that'll get data from a spreadsheet and print
it out to a txt file. I use the following:

Open "test.txt" For Output As #1
'some code
Write #1, "This is some test data"
'more code
Close #1

My problem is that I've written a few functions to write more data to
output, but I don't know how I can pass in #1(the open text file) to
these functions to let them be able to write to the file.

I tried closing the file before running the function, and then within
the function using the following:
Open "test.txt" For Append As #1
But that does nothing. Anybody know how I can do it then?
Thanks in advanced.


---
Message posted from http://www.ExcelForum.com/