Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Boiler Plateing text into another text document.

I am trying to import the content of a ".txt" file into a formatted
web page. I seem to have a good grasp on the writeing part but not the
reading (importing) part.

The following is where I am at at the moment:

Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\Tam\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\Tam\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(1)
Line Input #2, streng {I suspect my problem lays on this line}
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Saturday 12th September 0942hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub


This is what is produced:

<html<body<center<h2Heading</h2
Standard generated text - not imported
<table<tr<td
{Note: The imported text should appear in here.}
</td</tr<tr<td
Saturday 12th September 0942hrs
</td</tr</table</center</body</html

Your comments, suggestions and assistance would be greatly
appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default Boiler Plateing text into another text document.

I don't know what "H:\Tam\testText.txt" is and how you like to have your
"importBoPl.htm" look. I guessed this is what you are looking for but
I'm not sure.

Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\Tam\testText.txt"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table"
MyBoilerPlate = "H:\Tam\testText.txt"
Open MyBoilerPlate For Input As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, "<tr<td"
Print #1, streng
Print #1, "</td</tr"
Loop
Close #2
Print #1, "<tr<td"
Print #1, "Saturday 12th September 0942hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
Close #1
Close #2
End Sub

Keiji

Geoff E wrote:
I am trying to import the content of a ".txt" file into a formatted
web page. I seem to have a good grasp on the writeing part but not the
reading (importing) part.

The following is where I am at at the moment:

Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\Tam\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\Tam\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(1)
Line Input #2, streng {I suspect my problem lays on this line}
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Saturday 12th September 0942hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub


This is what is produced:

<html<body<center<h2Heading</h2
Standard generated text - not imported
<table<tr<td
{Note: The imported text should appear in here.}
</td</tr<tr<td
Saturday 12th September 0942hrs
</td</tr</table</center</body</html

Your comments, suggestions and assistance would be greatly
appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Boiler Plateing text into another text document.

On Sep 14, 12:47*pm, keiji kounoike <"kounoike A | T
ma.Pikara.ne.jp" wrote:
I don't know what "H:\Tam\testText.txt" is and how you like to have your
"importBoPl.htm" look. I guessed this is what you are looking for but
I'm not sure.

Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\Tam\testText.txt"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table"
MyBoilerPlate = "H:\Tam\testText.txt"
Open MyBoilerPlate For Input As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, "<tr<td"
Print #1, streng
Print #1, "</td</tr"
Loop
Close #2
Print #1, "<tr<td"
Print #1, "Saturday 12th September 0942hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
Close #1
Close #2
End Sub

Keiji



Geoff E wrote:
I am trying to import the content of a ".txt" file into a formatted
web page. I seem to have a good grasp on the writeing part but not the
reading (importing) part.


The following is where I am at at the moment:


Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\Tam\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\Tam\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(1)
Line Input #2, streng * *{I suspect my problem lays on this line}
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Saturday 12th September 0942hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub


This is what is produced:


<html<body<center<h2Heading</h2
Standard generated text - not imported
<table<tr<td
{Note: *The imported text should appear in here.}
</td</tr<tr<td
Saturday 12th September 0942hrs
</td</tr</table</center</body</html


Your comments, suggestions and assistance would be greatly
appreciated.- Hide quoted text -


- Show quoted text -



Keiji... Thank you for your reply

"H:\Tam\testText.txt" is the path to the file that contains the text
to be imported. That text is in the form of a collection of
paragraphs, much like that which you would expect to see in a letter.
It does not contain delimited data which would be subjected to further
processing.

"H:\" is the identity of a flash drive which I am using for testing
purposes.

"importBoPl.htm" Is the name of the destination file which is the
script for a web page.

I actually tried your routine but, unfortunately, it did not
work.However, there was some very useful information on there so I
adjusted my routine to reflect what I learnt from yours. It still does
not work, but it now looks like this:


Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\MsTamsin\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Page Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\MsTamsin\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, "streng"
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Monday 14th September 1327 hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub

Looking forward to further assistance on this matter.
Geoff E


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default Boiler Plateing text into another text document.

Geoff E wrote:
On Sep 14, 12:47 pm, keiji kounoike <"kounoike A | T
ma.Pikara.ne.jp" wrote:
I don't know what "H:\Tam\testText.txt" is and how you like to have your
"importBoPl.htm" look. I guessed this is what you are looking for but
I'm not sure.



Keiji... Thank you for your reply

"H:\Tam\testText.txt" is the path to the file that contains the text
to be imported. That text is in the form of a collection of
paragraphs, much like that which you would expect to see in a letter.
It does not contain delimited data which would be subjected to further
processing.

"H:\" is the identity of a flash drive which I am using for testing
purposes.

"importBoPl.htm" Is the name of the destination file which is the
script for a web page.

I actually tried your routine but, unfortunately, it did not
work.However, there was some very useful information on there so I
adjusted my routine to reflect what I learnt from yours. It still does
not work, but it now looks like this:


Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\MsTamsin\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Page Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\MsTamsin\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, "streng"
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Monday 14th September 1327 hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub

Looking forward to further assistance on this matter.
Geoff E


If you don't mind, let me know how did my code not work.
Anyway, I think the line Print #1, "streng" in your code above should be

Print #1, streng

("" should not be added)

In your code, Print #1, "streng" will write the string "Strng" itself
into the importBoPl.htm file.

I think you should put Close #1 and Close #2 in error handle. if not, if
error ocuurs, then you can't open your files next time.

P.S I wonder what the variable i means?

Keiji

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default Boiler Plateing text into another text document.

keiji kounoike wrote:
Geoff E wrote:
On Sep 14, 12:47 pm, keiji kounoike <"kounoike A | T
ma.Pikara.ne.jp" wrote:
I don't know what "H:\Tam\testText.txt" is and how you like to have your
"importBoPl.htm" look. I guessed this is what you are looking for but
I'm not sure.



Keiji... Thank you for your reply

"H:\Tam\testText.txt" is the path to the file that contains the text
to be imported. That text is in the form of a collection of
paragraphs, much like that which you would expect to see in a letter.
It does not contain delimited data which would be subjected to further
processing.

"H:\" is the identity of a flash drive which I am using for testing
purposes.

"importBoPl.htm" Is the name of the destination file which is the
script for a web page.

I actually tried your routine but, unfortunately, it did not
work.However, there was some very useful information on there so I
adjusted my routine to reflect what I learnt from yours. It still does
not work, but it now looks like this:


Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\MsTamsin\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Page Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\MsTamsin\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, "streng"
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Monday 14th September 1327 hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub

Looking forward to further assistance on this matter.
Geoff E


If you don't mind, let me know how did my code not work.
Anyway, I think the line Print #1, "streng" in your code above should be

Print #1, streng

("" should not be added)

In your code, Print #1, "streng" will write the string "Strng" itself
into the importBoPl.htm file.

I think you should put Close #1 and Close #2 in error handle. if not, if
error ocuurs, then you can't open your files next time.

P.S I wonder what the variable i means?

Keiji



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default Boiler Plateing text into another text document.

keiji kounoike wrote:
Geoff E wrote:
On Sep 14, 12:47 pm, keiji kounoike <"kounoike A | T
ma.Pikara.ne.jp" wrote:
I don't know what "H:\Tam\testText.txt" is and how you like to have your
"importBoPl.htm" look. I guessed this is what you are looking for but
I'm not sure.



Keiji... Thank you for your reply

"H:\Tam\testText.txt" is the path to the file that contains the text
to be imported. That text is in the form of a collection of
paragraphs, much like that which you would expect to see in a letter.
It does not contain delimited data which would be subjected to further
processing.

"H:\" is the identity of a flash drive which I am using for testing
purposes.

"importBoPl.htm" Is the name of the destination file which is the
script for a web page.

I actually tried your routine but, unfortunately, it did not
work.However, there was some very useful information on there so I
adjusted my routine to reflect what I learnt from yours. It still does
not work, but it now looks like this:


Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\MsTamsin\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Page Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\MsTamsin\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, "streng"
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Monday 14th September 1327 hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub

Looking forward to further assistance on this matter.
Geoff E


If you don't mind, let me know how did my code not work.
Anyway, I think the line Print #1, "streng" in your code above should be

Print #1, streng

("" should not be added)

In your code, Print #1, "streng" will write the string "Strng" itself
into the importBoPl.htm file.

I think you should put Close #1 and Close #2 in error handle. if not, if
error ocuurs, then you can't open your files next time.

P.S I wonder what the variable i means?

Keiji


I forgot to mention one more thing.
you opened MyBoilerPlate with output mode, but this should be opened as
input mode. so, your

Open MyBoilerPlate For Output As #2

should be

Open MyBoilerPlate For Input As #2

I made a mistake in my code that Myfile and MyBoilerPlate point to the
same file "H:\Tam\testText.txt". As the result, My code would not work
correctly.

Keiji
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Boiler Plateing text into another text document.

On Sep 14, 3:14*pm, keiji kounoike <"kounoike A | T ma.Pikara.ne.jp"
wrote:
keiji kounoike wrote:
Geoff E wrote:
On Sep 14, 12:47 pm, keiji kounoike <"kounoike A | T
ma.Pikara.ne.jp" wrote:
I don't know what "H:\Tam\testText.txt" is and how you like to have your
"importBoPl.htm" look. I guessed this is what you are looking for but
I'm not sure.


Keiji... Thank you for your reply


"H:\Tam\testText.txt" is the path to the file that contains the text
to be imported. That text is in the form of a collection of
paragraphs, much like that which you would expect to see in a letter.
It does not contain delimited data which would be subjected to further
processing.


"H:\" is the identity of a flash drive which I am using for testing
purposes.


"importBoPl.htm" Is the name of the destination file which is the
script for a web page.


I actually tried your routine but, unfortunately, it did not
work.However, there was some very useful information on there so I
adjusted my routine to reflect what I learnt from yours. It still does
not work, but it now looks like this:


Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\MsTamsin\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Page Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\MsTamsin\testText.txt"
Open MyBoilerPlate For Output As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, "streng"
i = i + 1
Loop
Close #2
Print #1, "</td</tr<tr<td"
Print #1, "Monday 14th September 1327 hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
End Sub


Looking forward to further assistance on this matter.
Geoff E


If you don't mind, let me know how did my code not work.
Anyway, I think the line Print #1, "streng" in your code above should be


Print #1, streng


("" should not be added)


In your code, Print #1, "streng" will write the string "Strng" itself
into the importBoPl.htm file.


I think you should put Close #1 and Close #2 in error handle. if not, if
error ocuurs, then you can't open your files next time.


P.S I wonder what the variable i means?


Keiji


I forgot to mention one more thing.
you opened MyBoilerPlate with output mode, but this should be opened as
input mode. so, your

Open MyBoilerPlate For Output As #2

should be

Open MyBoilerPlate For Input As #2

I made a mistake in my code that Myfile and MyBoilerPlate point to the
same file "H:\Tam\testText.txt". As the result, My code would not work
correctly.

Keiji- Hide quoted text -

- Show quoted text -


Again... thank you Keiji.

I now have it working just fine. This is what I ran with.

Public Sub importBoilerPlate()
Dim i As Long
Dim streng As String
On Error GoTo err_handler
ActiveWorkbook.Save
'================================================= ==================
Myfile = "H:\Tam\importBoPl.htm"
Open Myfile For Output As #1
Print #1, "<html<body<center<h2Heading</h2"
Print #1, "Standard generated text - not imported "
Print #1, "<table<tr<td"
MyBoilerPlate = "H:\Tam\testText.txt"
Open MyBoilerPlate For Input As #2
i = 0
Do While Not EOF(2)
Line Input #2, streng
Print #1, streng
Loop
Close #2
Print #1, "</td</tr"
Print #1, "<tr<td"
Print #1, "Saturday 12th September 1633 hrs"
Print #1, "</td</tr</table</center</body</html"
Close #1
'================================================= ====================
Exit Sub
err_handler:
MsgBox Err.Number & vbCrLf & Err.Description
Close #1
Close #2
End Sub

I think you nailed all the issues I had with your origional, but there
was one other one:

The "<tr<td" and "</td</tr" strings were somehow in the wrong
place and/or duplicated.
While the code may have been working the resulting "HTM" file would
not render.

Regards
Geoff
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically move text from one document to another BB Excel Worksheet Functions 1 September 22nd 09 07:02 PM
creating text document AJB Excel Discussion (Misc queries) 3 October 30th 08 03:27 PM
Find repeated text in a text document in Excel JE Excel Worksheet Functions 2 June 8th 08 09:32 PM
text disappears from document to excel gregp22 New Users to Excel 1 March 20th 06 04:51 PM
Replace text in an XML document [email protected] Excel Programming 0 May 16th 05 10:38 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"