convert html files to one doc file

S

sals

To anyone who wouldn't mind sharing their expertise...

I have a bunch of html files residing in a folder.

I need to write a program/macro in VB that will take in all the html
files in the folder.
Convert all the html files into word documents and merging it into one
big word document seperating each file with a page break.

any pointers will be aprreciated!


S
 
W

Word Heretic

G'day (e-mail address removed) (sals),

http://word.mvps.org/FAQs/index.htm

It has a skeleton for batch processing.

Then, define your output doc as a variable for easy reference. I'd do
something like (pseudocode only)

Set Final = Documents.Add ...
for every file in dir
open it, convert from HTML
add dummy para mark at end
copy everything bar last para mark
paste into the end of the Final
next


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


sals reckoned:
 
S

sals

Hi Steve,

Thanks for your expertise!
Would you where about the skeleton for batch processing is located?
I've been flipping thru the tabs and am unable to find it!

Please confirm:
Your suggestion is to use the batch file to read every file in the
folder?

could you please expain the para mark...
add dummy para mark at end
copy everything bar last para mark
paste into the end of the Final

Thanks,

S
 
W

Word Heretic

G'day (e-mail address removed) (sals),

That extra paragraph mark is so we minimize copying any nasty
corruption. Yes, the batch file skeleton reads files in a dir.

Its in the VBA tab, way way down the bottom of a very long and
incredibly juicy list of excellent information. The heading is

Working with files and directories

The title is

How to Find & ReplaceAll on a batch of documents in the same folder

The actual URL is

http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


sals reckoned:
 
S

sals

Thanks for the useful website Steve,

I'll give it a shot now that I have such a good outline!

Sals
 
S

sals

Hi Klaus,

Thanks for your link. It's really useful and I like how I can choose
different customization easily ie page breaks!

I have 4 htm files in the folder and am prompted with the screen what
would you like to convert your files from 4 times, is there a way to
make it such that I'm only prompted one time?

I enable the add page break option. But the last page is blank,
because of the inserted page break. Is there a way to take away the
last page?


Many thanks,

s
 
S

sals

Klaus,

I find that if I enable the page insert option, I get an extra page at the end.

So i changed the code from

For i = 1 To .FoundFiles.Count - 1
' If you want to insert the file name:
' Selection.TypeText .FoundFiles(i)
' Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), _
ConfirmConversions:=False
' If you want to insert a section break:
Selection.InsertBreak _
Type:=wdSectionBreakNextPage
Next i

To..

For i = 1 To .FoundFiles.Count - 1
' If you want to insert the file name:
' Selection.TypeText .FoundFiles(i)
' Selection.TypeParagraph
Selection.InsertFile FileName:=.FoundFiles(i), _
ConfirmConversions:=False
' If you want to insert a section break:
Selection.InsertBreak _
Type:=wdSectionBreakNextPage
Next i

Selection.InsertFile FileName:=.FoundFiles(i), _
ConfirmConversions:=False

And it worked fine.

Thanks for your code, it works beautifully!

S
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top