Text too long while exporting to .xml or .txt files

Bohucci

New Member
Joined
Dec 10, 2019
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi,

I want to export over 500 cells to separate .xml files. I wrote a macro in VB which is working (code below) but the exported text inside the exported .xml file is cut. The full text should have ~11500k characters and the exported one is ~8200 characters. I am missing the end part of the text.

Maybe the idea of how to solve this problem is to divide this text into 2 separate cells and combine them during the export? I would appreciate any help with writing a code for this action or any other solution.

Sub SaveAsXML()
Dim cell As Range
Dim FF As Long
Dim Counter As Long

For Each cell In Range("BB2", Range("BB" & Rows.Count).End(xlUp))
If cell.Value <> "" And Range("A" & cell.Row).Value <> "" Then
FF = FreeFile()
Open ThisWorkbook.Path & "\" & Range("C" & cell.Row).Value & ".xml" For Output As #FF
Print #FF, cell.Text
Close #FF
Counter = Counter + 1
End If
Next cell

MsgBox Counter & " files saved. ", , "XML Files Created"
End Sub


Best,
Bohucci
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
*The full text should have ~11500 characters and the exported one is ~8200 characters.
 
Upvote 0
Use Cell.Value instead of cell.text. The latter will truncate at 8,221 characters, I believe.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top