// чтение текстового файла в переменной Sub TextFile_PullData ()
Dim TextFile As Integer
Dim FilePath As String
Dim FileContent As String
'File Path of Text File
FilePath = "C:\data\R PAS\VBA\20190617\MyFile.txt"
'Determine the next file number available for use by the 'FileOpen function
TextFile = FreeFile
'Open the text file
Open FilePath For Input As TextFile
'Store file content inside a variable
FileContent = Input(LOF(TextFile), TextFile)
'Report Out Text File Contents
'MsgBox FileContent
'Close Text File
Close TextFile
//printing "Hello Friends to html page"
'conversion of text to html format
Dim sFile As Variant
sFile = Application.GetSaveAsFilename(fileFilter:="HTML Files (*.html), *.htm")
If Filename <> False Then
SaveWorkbook = Filename
End If
Open sFile For Output As #1
Print #1, "<html>"
Print #1, "<head>"
Print #1, "<title>Volcanoes!</title>"
Print #1, "</body>"
Print #1, "Hello Friends"
Print #1, "</body>"
Print #1, "</html>"
Close
End Sub
Выше кода печатается «Hello Friends» в HTML-файле, который я создал. Но я хочу напечатать содержимое текстового файла (читать в переменной) в HTML-файл.