Share via

save a word document as multiple html files

Anonymous
2012-04-08T12:04:47+00:00

Hi all,

I want to save a word 2007 document (.docx format, 100+ pages) as multiple html files for our website. The division can be based on the style that is already applied to the document, i.e. the content of each heading 1 is saved into one web page. I know Word 2007 has built-in html conversion feature, but it saves the document as one single html file. Anyone know how to do this? thanks.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

4 answers

Sort by: Most helpful
  1. Anonymous
    2012-04-08T12:14:42+00:00

    Here is a tjp that should point you in the right direction:

    How to Programmatically Save Each Page or Section of a Document As Separate File

    http://support.microsoft.com/?kbid=216845

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2012-04-09T08:56:29+00:00

    Thanks Doug,

    I follow your instructions and run the modified VB code. Multiple HTML files are generated and they are named test_n.htm where n=1..19.

    Now everything is OK except only one issue. The file test_1.htm corresponds to the title and content of the original document, and the files test_2.htm, test_3.htm ... correspond to chapter 1, 2 ... of the document. In original word document, I can ctrl+click an entry in the content to jump to the corresponding chapter, in test_1.htm however, all links are assigned as file:///D:\Public\test_1.htm. Is there any way to solve this issue? Thanks in advance.

    Was this answer helpful?

    0 comments No comments
  3. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2012-04-09T01:18:25+00:00

    Thanks Rohn007.

    But there are still two problems. First, the ordinal index number of each section is incorrectly changed to 1. For example, the section title of original document

    "chapter 10 section-title"

    is changed to

    "chapter 1 section-title'

    Second, we still have to convert each divided document into html file. This may be inpractical as there are 20 divided documents.

    Before splitting the document, run a macro containing the command

    ActiveDocument.ConvertNumbersToText

    Replace the following line of code in the article to which you were referred

     ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"

    with

     ActiveDocument.SaveAs filename:="test_" & DocNum & ".htm", FileFormat:=wdFormatHTML

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2012-04-08T15:59:42+00:00

    Thanks Rohn007.

    But there are still two problems. First, the ordinal index number of each section is incorrectly changed to 1. For example, the section title of original document

    "chapter 10 section-title"

    is changed to

    "chapter 1 section-title'

    Second, we still have to convert each divided document into html file. This may be inpractical as there are 20 divided documents.

    Was this answer helpful?

    0 comments No comments