Stuart McLachlan
stuart at lexacorp.com.pg
Tue Aug 5 17:05:37 CDT 2008
Yep, another ommission on my part ( I did warn you <g>)
You need to do a
Close #1
after
Loop Until strFile = ""
to close the last merge file.
It's not using any objects, so there is no need to do anything else.
On 5 Aug 2008 at 15:22, Darren D wrote:
>
> Stuart - Fantastic
>
> Works an absolute treat many many thanks - you are a legend
>
> What is the standard code bits to get it to release the file whilst the dB is
> open? I also assume there are objects to be closed or set to nothing - yes?
>
> Code working nicely below
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Private Sub ps_CopyBlocks()
>
> On Error Resume Next
>
> Dim lngCounter As Long
> Dim lngFileCounter As Long
> Dim strFile As String
> Dim strMergeFile As String
>
> strMergeFile = "MergeFile00.txt"
> Open strMergeFile For Output As #1
> strFile = Dir$("*.xml")
> Do
> Open strFile For Input As #2
> While Not EOF(2)
> Line Input #2, strtemp
> Print #1, strtemp
> Wend
> Close #2
> lngCounter = lngCounter + 1
> If lngCounter = 10 Then
> lngFileCounter = lngFileCounter + 1
> lngCounter = 0
> Close #1
> strMergeFile = "MergeFile" & Format(lngFileCounter, "00" & ".txt")
> Open strMergeFile For Output As #1
> End If
> strFile = Dir$
> Loop Until strFile = ""
>
> End Sub