Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default What is FreeFile() function???

I'm trying to understand what exactly is the purpose of the
VBA FreeFile() function??? If I call this function inside
one of my VBA modules, it will return a numerical value.
What is this numerical value??

thank you




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default What is FreeFile() function???

"Robert Crandal" wrote in message
...
I'm trying to understand what exactly is the purpose of the
VBA FreeFile() function??? If I call this function inside
one of my VBA modules, it will return a numerical value.
What is this numerical value??

thank you


Robert,

Here are two ways of accessing rather immediate assistance

1. VBA Help
Search "freefile". It lays it out in plain english.

2. Google. Here's one of many hits.
http://zo-d.com/blog/archives/progra...ect-excel.html
In the first paragraph at this site, it states "Use FreeFile to get the
file number of the next file."

Pretty straightforward.

Skiffle

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default What is FreeFile() function???

Robert,

In VB you can open files and then manipulate them using FileNum.

Now in a simple piece of code you could use Filenum 1 (one) manually
assigned in the fairly certain knowledge the number isn't being used but in
more complicated code this become very risky indeed because if you manually
assign the number you may start geting uppredictable results.

Hence FreeFile() which allocates the next 'unused' number. In the snippet
below Filenum is assigned to the next free number by FreeFile and thereafter
the file is referred to by the number assigned to it and not the name


Dim FileNum As Integer
LogMessage ="Some very important text"
FileNum = FreeFile
Open FName For Append As #FileNum
Print #FileNum, LogMessage
Close #FileNum ' close the file
End Sub


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Robert Crandal" wrote:

I'm trying to understand what exactly is the purpose of the
VBA FreeFile() function??? If I call this function inside
one of my VBA modules, it will return a numerical value.
What is this numerical value??

thank you




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default What is FreeFile() function???

Thank you so much for the info. It is always appreciated!

Robert


"Mike H" wrote in message
...
Robert,

In VB you can open files and then manipulate them using FileNum.

Now in a simple piece of code you could use Filenum 1 (one) manually
assigned in the fairly certain knowledge the number isn't being used but
in
more complicated code this become very risky indeed because if you
manually
assign the number you may start geting uppredictable results.

Hence FreeFile() which allocates the next 'unused' number. In the snippet
below Filenum is assigned to the next free number by FreeFile and
thereafter
the file is referred to by the number assigned to it and not the name


Dim FileNum As Integer
LogMessage ="Some very important text"
FileNum = FreeFile
Open FName For Append As #FileNum
Print #FileNum, LogMessage
Close #FileNum ' close the file
End Sub



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
User Function Question: Collect Condition in Dialog Box - But How toInsert into Function Equation? SteveM Excel Programming 1 January 3rd 08 04:45 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 11:46 PM


All times are GMT +1. The time now is 07:55 AM.

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

About Us

"It's about Microsoft Excel"