error 14 - out of string space
Colin, this indicates a really complex problem that may be due to a badly chosen string manipulation pattern. Here is what I understand about "string space" - and it will probably be about as clear as space-time string theory. I hope it is better than that...
String space is part of a process memory that is pre-allocated as a working area. When you create and dissolve strings in VBA, the intermediates have to go somewhere, and this "somewhere" is part of a program structure known as the
heap. The string VARIABLE actually doesn't change places for the life of the string - but a component of that variable DOES change. You see, a string variable is actually a BSTR structure, which you can look up online.
http://bytecomb.com/vba-internals-string-variables-and-pointers-in-depth/
There is a string count and a string location in the actual structure. The important thing to know about this is, you can completely replace the value of a string without moving the string variable - which is good, because for subroutines, almost all variables (excluding those declared as Static) are on the stack.
The way that VBA (and many other languages) optimize string usage is that there is this area where if you have a string, the variable has a string length and a string "actual location," and that actual location is a working memory area that is part of your process virtual memory.
If you modify a string, rather than diddle the bytes, VBA makes a new copy of the modified string elsewhere and then change the length and location fields. Then VBA releases the previous set of bytes for possible re-use. Possible - but due to potential size mismatches, unlikely. Look up "memory + garbage collection" for a discussion on the perils of that particular procedure.
This working area in the heap cannot be infinite in size, obviously. A certain amount of memory space has to be set aside for it - and the starting size of course is some obscure tuning parameter. When you create and destroy strings A LOT, particularly with size changes, you run into the problem of "thrashing" the working area and causing it to be badly fragmented. Once it gets fragmented badly enough, you cannot create new strings of any appreciable length because you can't allocate contiguous bytes for it.
THEREFORE, if you see the "out of string space" message, you have an issue with the way strings are being created and destroyed in your program. Note also that the stack depth IS NOT an issue because all routines in your app share the same heap area. When the total of all functions and subs "blows out" your heap space, you get that error.
https://support.microsoft.com/en-us...f-memory-error-message-because-of-the-desktop - is an article on how to change the size of your program heap. Note also that an x32 system and an x64 system will have vastly different heap sizes because x64 systems have more room to "play with" in terms of physical memory allocation.