fitchic77
06-22-2001, 11:17 AM
Since I am a newbie, I need to know how I can build/create a file dynamically (XML/HTML or whatever). I am not sure if I open a file, somehow add the data to it, save it???
Any help would be GREATLY appreciated!!!
Thanks,
Andrea
:>)
An html file is just a specially formatted text file. Do a search for "text files" in the Visual Basic Help section, and you should find some answers easily enough.
Basically, you want to open a file for output access and print some information to it. Something like this:
<pre>
Dim FileName as String, FileNum as Integer
FileNum = FreeFile() <font color=green>'Returns the next available file number (VB accesses files by number, rather than name)</font color=green>
FileName = "C:\MyDir\MyFile.html"
Open FileName For Output as # FileNum
Print #FileNum "whatever text you want"
Print #FileNum "Some more text"
</pre>
or something like that...
fitchic77
06-22-2001, 01:32 PM
I had compilation errors. So I tinkered around and got it to work as below. Here is how I got it to work.
Dim FileName As String
Dim FileNum As Integer
FileNum = FreeFile() 'Returns the next available file number (VB accesses files by number, rather than name)
FileName = "C:\VBA\MyFile1.html"
Open FileName For Output As #FileNum
Print #FileNum, "w"
Print #FileNum, "Some more text"
Close #FileNum
Yup - my apologies - I forgot the commas.
Close is also an important statement.
I'm glad you were able to figure it out.