K
Keith
When I run the following code, I receive the following runt-time error:
Run-time error '55':
File already open
####################code
Public Sub InventoryCSVProcessing()
Dim filenumin As Integer, filenumout As Integer, filenuminraw As Integer,
filenumoutraw As Integer
Dim InputString As String
Dim intCount As Integer
filenuminraw = FreeFile
filenumoutraw = FreeFile
Open "x:\xlapps\cessna\inventory.csv" For Input As filenuminraw
'Read first 7 lines to skip the header junk
'For intCount = 1 To 7
' Line Input #filenumin, InputString
'Next intCount
Line Input #filenuminraw, InputString
InputString = Replace(InputString, Chr(10), Chr(13) & Chr(10))
Debug.Print InputString
If Dir("x:\xlapps\cessna\inventoryraw.csv") <> "" Then
Kill "x:\xlapps\cessna\inventoryraw.csv"
End If
'Error occurs on following line
Open "x:\xlapps\cessna\inventoryraw.csv" For Output As #filenumoutraw
Print #filenumoutraw, InputString
Close #filenumoutraw
Close #filenuminraw
######################end of code
I tried adding a 15 second delay before opening the file for output, and it
worked one time. It think the problem is the Kill statement, but I need to
delete the existing file before I write data.
Have anyone else seen this behavior? Any thoughts on how to fix it?
Thanks,
Keith
Run-time error '55':
File already open
####################code
Public Sub InventoryCSVProcessing()
Dim filenumin As Integer, filenumout As Integer, filenuminraw As Integer,
filenumoutraw As Integer
Dim InputString As String
Dim intCount As Integer
filenuminraw = FreeFile
filenumoutraw = FreeFile
Open "x:\xlapps\cessna\inventory.csv" For Input As filenuminraw
'Read first 7 lines to skip the header junk
'For intCount = 1 To 7
' Line Input #filenumin, InputString
'Next intCount
Line Input #filenuminraw, InputString
InputString = Replace(InputString, Chr(10), Chr(13) & Chr(10))
Debug.Print InputString
If Dir("x:\xlapps\cessna\inventoryraw.csv") <> "" Then
Kill "x:\xlapps\cessna\inventoryraw.csv"
End If
'Error occurs on following line
Open "x:\xlapps\cessna\inventoryraw.csv" For Output As #filenumoutraw
Print #filenumoutraw, InputString
Close #filenumoutraw
Close #filenuminraw
######################end of code
I tried adding a 15 second delay before opening the file for output, and it
worked one time. It think the problem is the Kill statement, but I need to
delete the existing file before I write data.
Have anyone else seen this behavior? Any thoughts on how to fix it?
Thanks,
Keith