Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

saving to a text file- help needed badly

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hello all. Anyway, my question for you all is about writing to a specific line , or after a specific charator(s) in a text file. I am currently writing a simple html generator, and there is a text box in which you will type the body of the html file. what i am wanting to do is this: when the document is saved, the program should automaticaly write:
<html>
<head>
</head>
<title>
on the form, there will be a place to enter the title of the web page, and that entry field will place the text contained in it after the title tag, then it will place </title> after that. then the program will automatically write:
<body>
to the html file. in the text box you wil type what you want the body to say. when you save, the program will insert:
</body>
at the end of the html file.
my question is... HOW DO I DO THIS??? [sig][/sig]
 
Dim FileName As String
Dim FileNum As Integer

FileNum = FreeFile
FileName = App.Path & &quot;\&quot; & Format(Now(), _
&quot;yyyymmddhhmmss&quot;) & &quot;.html&quot; 'create unique name
Open FileName For Append As #FileNum

Print #FileNum, &quot;<html>&quot;
Print #FileNum, &quot;<head>&quot;
Print #FileNum, &quot;<title>&quot;
Print #FileNum, txtTitle.Text
Print #FileNum, &quot;</title>&quot;
Print #FileNum, &quot;<body>&quot;
Print #FileNum, txtBody.Text
Print #FileNum, &quot;</body>&quot;
Print #FileNum, &quot;</html>&quot;
Close #FileNum
MsgBox &quot;written &quot; & FileName
[sig]<p>Simon<br>[/sig]
 
thanks a lot for the code, it works great. i have one question though... how do i get rid of the date etc. name? i want the name to always be something like &quot;index.html&quot; or something. eventually i want to have the name be the variable of a imput box... but anway, how would i make it so that i assign the name of the file? [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top