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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert text From Multiple Files 1

Status
Not open for further replies.

PaultheITGuy

Technical User
Jan 19, 2007
52
GB
Hi,

I wonder if anyone can help.

I would like to import the text from over 1000 htm files. This in itself is not a problem, but I would like to import them so each htm file is imported to a new page.

Is there any way to do this without doing them all individually?

Thanks

Paul C
 
Hi Paul.

Import where?
Excel? Word? If you say "each on a new page" the I presume we are talking about Word?
Are the HTMs all stored in one folder or in several?
Specific text or all of the text in the HTMs?
Shall links be preserved? Tables?
Etc.


[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Hi - Word 2007.

I want to import the text only from each htm file - no formatting/links to be preserved.

HTMs are all in one folder.

Thanks

Paul C
 
Hi Paul,

1. Word 2007: this is important because this version's VBA does not support the Application.FileSearch method any longer

2. You said: "This in itself is not a problem, but I would like to import them so each htm file is imported to a new page."

What do you have already? I assume some For...Next loop.
After inserting the text of the HTM into the Word doc and before going to the next HTM, insert a line like this
Code:
ran.InsertBreak wdPageBreak
With "ran" being a variable of type Range.

Cheers,
MiS

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
Hi - I'm not a programmer so I have no idea what this means.

At the minute I am going to Insert --> Object --> Text From File

And what it does is it inserts the text from each file with only a line break between each - I want it to insert a page break.
 


... I want it to insert a page break.

What is stopping YOU?

BTW, Your Macro recorder might help.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
To insert text from multiple files to word you have to select them all and then they are inserted one after the other with only a line break.

I want to insert 1700 htm files at once so I do not want to have to insert one, hit "Page break" insert the next, hit "page break" 1700 times as it will take hours.
 
To insert text from multiple files to word you have to select them all and then they are inserted one after the other with only a line break."

What do you mean "select them all"

"HTMs are all in one folder." Good, then look at using the DIR function. It will do the job.

"And what it does is it inserts the text from each file with only a line break between each - I want it to insert a page break. "

Then you must use a macro. Again, use the Dir function.

Also, look at the INCLUDETEXT field. Between it and Dir, you can do this. However, this is a VBA question, so please ew-post in that forum.

Gerry
 
If the files have some common value in the header or footer, you could use Replace to insert a page break, which is ^m.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Madawc - I used your suggestion in the end.

Did a mass find and replace int he html code with Dreamweaver and replaced "</html>" in every file with "pagebreak</html>"

The after importing all the files into Word I did a replace of pagebreak with ^m

That did the trick nicely.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top