Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / July 2006

Tip: Looking for answers? Try searching our database.

How do I output Word 2003 merge as HTML?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
M.L. - 09 Jul 2006 16:53 GMT
Hi. I'm just learning how to use Word 2003 mail merge to create
HTML templates for my website. The only problem is that the
resulting pages are output as .doc files instead of .html. Is there
a way I can set mail merge options to output my result as HTML
files instead? Thanks.
Graham Mayor - 10 Jul 2006 04:55 GMT
Look at the variety of file types you can save a document as from the File >
Save As dialog!

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Hi. I'm just learning how to use Word 2003 mail merge to create
> HTML templates for my website. The only problem is that the
> resulting pages are output as .doc files instead of .html. Is there
> a way I can set mail merge options to output my result as HTML
> files instead? Thanks.
M.L. - 10 Jul 2006 07:55 GMT
>> Hi. I'm just learning how to use Word 2003 mail merge to create
>> HTML templates for my website. The only problem is that the
>> resulting pages are output as .doc files instead of .html. Is there
>> a way I can set mail merge options to output my result as HTML
>> files instead? Thanks.

> Look at the variety of file types you can save a document as from the
> File > Save As dialog!

Thanks for your reply. However, the Word 2000 mailmerge does not
offer a Save As dialog box when it gets ready to merge the document.
The results are automatically saved as .doc files.
Graham Mayor - 10 Jul 2006 09:03 GMT
Oops - sorry, I hadn't had my breakfast when I wrote that. I was forgetting
which group I was in.

You could output to a new document and use the splitter macro from
http://www.gmayor.com/individual_merge_letters.htm to break to individual
documents saved as html.

Change the fileformat in the line
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument
to
wdFormatHTML
and the extension in the line
DocName = "D:\My Documents\Temp\Workgroup\" & Format(Date, mask) _
& " " & LTrim$(Str$(Counter)) & ".doc"
from doc to htm

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

>>> Hi. I'm just learning how to use Word 2003 mail merge to create
>>> HTML templates for my website. The only problem is that the
[quoted text clipped - 8 lines]
> offer a Save As dialog box when it gets ready to merge the document.
> The results are automatically saved as .doc files.
M.L. - 11 Jul 2006 01:49 GMT
>>>> Hi. I'm just learning how to use Word 2003 mail merge to create
>>>> HTML templates for my website. The only problem is that the
[quoted text clipped - 9 lines]
>> offer a Save As dialog box when it gets ready to merge the document.
>> The results are automatically saved as .doc files.

> Oops - sorry, I hadn't had my breakfast when I wrote that. I was
> forgetting which group I was in.
[quoted text clipped - 11 lines]
> & " " & LTrim$(Str$(Counter)) & ".doc"
> from doc to htm

I don't know much about scripting and expected something
simpler. But if I have to I'll give it a try. Thanks again.
M.L. - 14 Jul 2006 22:27 GMT
>>>>> Hi. I'm just learning how to use Word 2003 mail merge to create
>>>>> HTML templates for my website. The only problem is that the
[quoted text clipped - 27 lines]
> I don't know much about scripting and expected something
> simpler. But if I have to I'll give it a try. Thanks again.

While trying to solve my mailmerge conversion issue I Googled upon
a May 7, 2004 post of yours which explained this issue in more detail.
Specifically, you wrote the following macro to convert doc files to HTML:
*******************************
Public Sub BatchSaveAsHTML()
Dim myFile As String
Dim myHTML As String
Dim myLen As String
Dim myLen2 As String
Dim PathToUse As String
Dim myDoc As Document

With Dialogs(wdDialogCopyFile)
   If .Display <> 0 Then
       PathToUse = .Directory
   Else
       MsgBox "Cancelled by User"
       Exit Sub
   End If
End With

If Documents.Count > 0 Then
   Documents.Close Savechanges:=wdPromptToSaveChanges
End If

If Left(PathToUse, 1) = Chr(34) Then
   PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If

myFile = Dir$(PathToUse & "*.doc")

While myFile <> ""
   Set myDoc = Documents.Open(PathToUse & myFile)
   myLen = Len(myFile)
   myLen2 = myLen - 3
   myHTML = Left(myFile, myLen2) & "HTML"
   myDoc.SaveAs FileName:=myHTML, FileFormat:=wdFormatHTML
   myDoc.Close Savechanges:=wdSaveChanges
   myFile = Dir$()
Wend
End Sub
*********************************************

I notice that your reply contains some slight changes from the earlier
version.
I installed your macro and it worked well, and was faster than I thought
it would be. However, I do have some questions:

1.) The output HTML files were saved to the "my documents folder." Is there
a way I can set the output files to the folder of my choice? Or could I at
least set the
output to be saved in the same folder from which I loaded my original doc
files?

2.) The HTML is not filtered and therefore I get some extra data in the HTML
source. Is there a way I can clean up the HTML during the macro?

3.) Does it matter that the Word default macro template does not contain
the word "Public" preceeding the word sub?

In addition, when I went to your website I downloaded the macro that splits
the
merged file into separate files (MMtoDocsRev19.dot). Your tutorial on that
macro
showed some familiar screenshots. I realized that your macro was already on
my
Word 2003 system, even though I don't remember ever having placed it there.
It is located in my Applications Data\Microsoft\Word startup folder
as MailMergetoDocsRev19.dot. Are the two files equivalent?

I'd like to again thank you so much for all your assistance in this matter.
Peter Jamieson - 16 Jul 2006 14:49 GMT
Graham's website suggests he's out of the picture for a few weeks, so I'll
answer what I can...

> 1.) The output HTML files were saved to the "my documents folder." Is
> there
> a way I can set the output files to the folder of my choice? Or could I at
> least set the
> output to be saved in the same folder from which I loaded my original doc
> files?

The values returned by "Dir()" are just the file names, not the full path
names, so in this case you could  you could change

myHTML = Left(myFile, myLen2) & "HTML"

to

myHTML = PathToUse & Left(myFile, myLen2) & "HTML"

(It seems that Graham is already assuming that PathToUse is empty or ends
with a "\" or just contains "<a drive letter>:")

> 2.) The HTML is not filtered and therefore I get some extra data in the
> HTML
> source. Is there a way I can clean up the HTML during the macro?

Try changing

myDoc.SaveAs FileName:=myHTML, FileFormat:=wdFormatHTML

to

myDoc.SaveAs FileName:=myHTML, FileFormat:=wdFormatFilteredHTML

> 3.) Does it matter that the Word default macro template does not contain
> the word "Public" preceeding the word sub?

Not really, when you're just running the macro as a one-off in this way.
When you're writing a suite of macros, getting declarations such as this one
"correct" becomes more important if not critical. But you'ld be better off
asking in a general VBA programming group about that.

> It is located in my Applications Data\Microsoft\Word startup folder
> as MailMergetoDocsRev19.dot. Are the two files equivalent?

Don't know, sorry. Doug Robbins may be able to tell you if you post another
message (don't use the same title) just describing this one issue.

Peter Jamieson

>>>>>> Hi. I'm just learning how to use Word 2003 mail merge to create
>>>>>> HTML templates for my website. The only problem is that the
[quoted text clipped - 103 lines]
> I'd like to again thank you so much for all your assistance in this
> matter.
M.L. - 17 Jul 2006 16:23 GMT
>>>>>>> Hi. I'm just learning how to use Word 2003 mail merge to create
>>>>>>> HTML templates for my website. The only problem is that the
[quoted text clipped - 103 lines]
>> I'd like to again thank you so much for all your assistance in this
>> matter.

> Graham's website suggests he's out of the picture for a few weeks, so I'll
> answer what I can...
[quoted text clipped - 45 lines]
>
> Peter Jamieson

Thanks Peter, I'll incorporate the changes into the macro. BTW, I found that
Word has an option that allows me to save *all* files as filtered HTML. I
could just set that option on or off when needed.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.