VBA code to create n number of txt/doc/xls files with specific size.
Hi all,,,,,,,,,
Plzzzzzzz help me with the vb code to create n number of files with specific size.
I have a code which would create text/word/excel files .....But I tried this code to create 'n' number of files....
To be clear.....I need to create 1000 txt files with the content as 'Hello World1' 'Hello word2'.............'Hello World1000' respectively..........
And If i specify the size of the file in a text box then it should create the file with that size.....
But I couldn't make it...................help me this out..........
The following is the code ........
Public Sub veeru()
Const FILENAME = "C:\Users\veeru\Desktop\myfile.xls"
Dim My_filenumber As Integer
My_filenumber = FreeFile
Open FILENAME For Output As #My_filenumber
Write #My_filenumber, "Hello"
Close #My_filenumber End Sub
:(:(:confused::confused::confused:
Re: VBA code to create n number of txt/doc/xls files with specific size.
Have a look into For..Next loops
The Write line could look like this:
Code:
Write #My_filenumber, "Hello World " & Cstr(i)
With i beeing the Looping Variable.
BTW This is the VB Forum, for VBA questions, the Office Development section is suited better!
Re: VBA code to create n number of txt/doc/xls files with specific size.
Quote:
Const FILENAME = "C:\Users\veeru\Desktop\myfile.xls"
why would you create text files with .xls extension?
to make text files of specific size you would need to pad the string written to the file with some character or spaces, to make the difference between the string size and the desired file size, using either the string or space methods