Answered by:
Exporting Long String from VBA

Question
-
Experts -
I have a requirement to build a long string (thousands of characters) in VBA and export to a text file. At the moment this is being accomplished via a query, however the query limits the string to 255 characters.
Are there any workarounds? I am facing the same problem when loading the string to a table, even when using the memo data data type.
Thanks!
Bonediggler
Wednesday, July 27, 2016 7:30 PM
Answers
-
OK, you’re in VBA already, why not keep it there.
You’ve built your string already, so use the VBA “interface” to text files like the (obscure) help example:
Open "TESTFILE" For Output As #1
Write #1, "Hello World", 234 ' comma-delimited
Consider also the “Print #” statement
You will be looking in the VBA Language Reference help file (good, actually, when you find it).
peter n roth - http://PNR1.com, Maybe some useful stuff
- Marked as answer by Bonediggler Thursday, July 28, 2016 6:26 PM
Wednesday, July 27, 2016 9:26 PM -
Hi Bonediggler,
you had mentioned the 3 steps in your last post and mentioned that you have a problem with the 3 step.
so For more examples of how to export the string to text file please visit link below.
The VBA Guide To Interacting With Text (.Txt) Files
Hope this helps you to solve your issue.
Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Regards
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Marked as answer by Bonediggler Thursday, July 28, 2016 6:26 PM
Thursday, July 28, 2016 5:06 AM
All replies
-
Hey Bone -
Work around what, exactly?
peter n roth - http://PNR1.com, Maybe some useful stuff
Wednesday, July 27, 2016 8:32 PM -
Hi Peter -
Sorry about the lack of detail. Basically the process is to:
1) Import one to thousands of codes into a table
2) Build a string in VBA to get these codes in a particular format
3) Export the formatted string to a text file
Steps 1 and 2 are fine. The bottleneck is getting the string to the text file. If I put it in a table, it gets cut off at 255 chars (even using Memo). If I put it in a query via QueryDef.sql I have the same problem. As such, I'm not sure what method is available to accomplish this...?
Bonediggler
Wednesday, July 27, 2016 9:07 PM -
OK, you’re in VBA already, why not keep it there.
You’ve built your string already, so use the VBA “interface” to text files like the (obscure) help example:
Open "TESTFILE" For Output As #1
Write #1, "Hello World", 234 ' comma-delimited
Consider also the “Print #” statement
You will be looking in the VBA Language Reference help file (good, actually, when you find it).
peter n roth - http://PNR1.com, Maybe some useful stuff
- Marked as answer by Bonediggler Thursday, July 28, 2016 6:26 PM
Wednesday, July 27, 2016 9:26 PM -
Hi Bonediggler,
you had mentioned the 3 steps in your last post and mentioned that you have a problem with the 3 step.
so For more examples of how to export the string to text file please visit link below.
The VBA Guide To Interacting With Text (.Txt) Files
Hope this helps you to solve your issue.
Disclaimer: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Regards
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- Marked as answer by Bonediggler Thursday, July 28, 2016 6:26 PM
Thursday, July 28, 2016 5:06 AM