用户登录
用户注册

分享至

word转换为htm编码

  • 作者: 浮生半日闲人
  • 来源: 51数据库
  • 2020-04-21

请问如何将word文件转化成htm文件

<div style="border:1 outset #ffffff; overflow:auto;width:80%;height:50%" id="word" contenteditable></div>

<input type="button" value="转换成HTML" onclick="convert2html()"><br>

<textarea cols="80" rows="10" id="html"></textarea><br>

注意:您的浏览器必须是IE5.5后以上,否则无法插入文字!

</body></html>

这是另一种实现方法:

<html>

<HEAD>

<TITLE>WalkingPoison's Word-to-HTML sample</TITLE>

<script language=javascript>

function saveword(){

var oWordApp=new ActiveXObject("Word.Application");

var oDocument=oWordApp.Documents.Open("C:\\sss.doc");

oDocument.SaveAs("C:\\test.htm", 8)

oWordApp.Quit();}</script>

</HEAD>

<BODY>

Click the "save" button to save the file "C:\test.doc" to "C:\test.htm":

<input type=button onclick="saveword()" value=save>

<P> </P>

word并按章节转化为多个htm文件

1、首先需要将原文档进行分节,即在需要分割的地方插入换页分节符;

2、Alt+F11打开VBA编辑器;

3、选择菜单命令“插入-模块”;

4、在代码编辑区中输入如下代码:

Sub SplitAsHTMLs()

Const strFileExtension = ".docx"

Dim oSection As Section

Dim strTargetFileName As String

For Each oSection In ActiveDocument.Sections

strTargetFileName = Replace(ActiveDocument.FullName, strFileExtension, "_" & oSection.Index & ".html")

oSection.Range.ExportFragment strTargetFileName, wdFormatHTML

Next

MsgBox "完成"

End Sub

5、如果楼主的Word文档是.doc的话,需要替换代码中的“.docx”为“.doc”;

6、键入F5,运行。

检查在原文档相同目录下生成了若干个html文件,文件名是原文件后面加_1、_2、_3等,每个html对应原来的一个节(用换页分节符分割的部分)。

如何将word文件转化成htm文件

方法/步骤

打开word文档,单击菜单栏中的“文件”,找到“另存为” 或“另存为网页”,

单击另存为” 或“另存为网页”,弹出"另存为" 窗口,

在"另存为" 窗口的“保存类型”,下拉菜单中找到“网页”。

在“文件名”一栏中可以修改我们想要的文件名,如图我改成了“经验”。

点“保存”,就把一篇word文档保存成网页格式了。我保存在桌面了。

这时候在桌面就可以找到保存的网页,然后用浏览器会打开并显示网页的内容。

转载请注明出处51数据库 » word转换为htm编码

软件
前端设计
程序设计
Java相关