Using FreeFile(1) and trying to open a file
Posted on 2005-04-11
Here's the code...
Dim intContractFile as Integer
intContractFile = FreeFile(1)
Open strDataPath & "\LARCONTR" For Random As #intContractFile Len = 220
When I check the debug progress, intContractFile = 256
Here's the error...
Run-Time Error '5':
Invalid Procedure Call or Argument
The open command in the help file shows this as a file number argument:
filenumber: Required. A valid file number in the range 1 to 511, inclusive. Use the FreeFile function to obtain the next available file number.
** AND **
filenumber: Number used in the Open statement to open a file. Use file numbers in the range 1-255, inclusive, for files not accessible to other applications. Use file numbers in the range 256-511 for files accessible from other applications.
And here's what FreeFile says:
FreeFile[(rangenumber)] :The optional rangenumber argument is a Variant that specifies the range from which the next free file number is to be returned. Specify a 0 (default) to return a file number in the range 1 255, inclusive. Specify a 1 to return a file number in the range 256-511.
I'm at a loss. I need help. I need to open the file in the higher range because the file IS being used by other applications.