ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What's the best way of writting a text file through VBA? (https://www.excelbanter.com/excel-programming/375764-whats-best-way-writting-text-file-through-vba.html)

salut

What's the best way of writting a text file through VBA?
 
I have to create several text files through VBA every month, and the text
files have to be created line by line. What I do right now is to write to the
text file everytime I created a new line for this text file. And it became
extremely slow when everything is located on a network drive. I am guessing
the major reason is because writing to the network drive frequently makes the
process slow.

So I am thinking about if it is possible to put the data for the text file
in a buffer and then save it to the network drive only once. The text file is
not huge, its size is just about 3M. Saving a 3M file on the network drive
should just take a few seconds, at most 1 minute.

Could anybody help me on this problem? Thanks a lot!

Dave Peterson

What's the best way of writting a text file through VBA?
 
So why not write to your C: drive (maybe a temp folder) and just move the file
to the network drive when you're done?

Look at Name Statement in VBA's help:

salut wrote:

I have to create several text files through VBA every month, and the text
files have to be created line by line. What I do right now is to write to the
text file everytime I created a new line for this text file. And it became
extremely slow when everything is located on a network drive. I am guessing
the major reason is because writing to the network drive frequently makes the
process slow.

So I am thinking about if it is possible to put the data for the text file
in a buffer and then save it to the network drive only once. The text file is
not huge, its size is just about 3M. Saving a 3M file on the network drive
should just take a few seconds, at most 1 minute.

Could anybody help me on this problem? Thanks a lot!


--

Dave Peterson


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com