'loStreamWriter.Write(toStringBuilder.ToString()) 'do not use this one ' use this instead loStreamWriter.Write(toStringBuilder)Did you try this variation and still run into memory problems?
> Dim loFileStream As FileStream = Nothing > Dim loStreamWriter As StreamWriter = Nothing > > Try > loFileStream = New FileStream(cFile, FileMode.Create) > loStreamWriter = New StreamWriter(loFileStream, System.Text.Encoding.Unicode) > > Catch loError As Exception > cMessage = oApp.StrTran(cCannotCreateFile, "##File##", cFile) > > ' If we log the error > If lLogError Then > > ' Get the proper definition as per the current scope > If oProcess Is Nothing Then > oApp.ErrorSetup(loError) > Else > oProcess.ErrorSetup(loError) > End If > > Else > Return False > End If > > End Try > > ' Header > loStreamWriter.Write("<?xml version=""1.0""?>" + oApp.cCR) > > ' Windows recognition > loStreamWriter.Write("<?mso-application progid=""Excel.Sheet""?>" + oApp.cCR) > > ' Workbook > loStreamWriter.Write("<Workbook xmlns=""urn:schemas-microsoft-com:office:spreadsheet"" " + oApp.cCR) > loStreamWriter.Write("xmlns:o=""urn:schemas-microsoft-com:office:office"" " + oApp.cCR) > > ... > > loStreamWriter.Close() > loFileStream.Close() >