惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 琼

服务器 'server_1' 上的 MSDTC 不可用 - 琼 Asp.Net中用javascript实现弹出窗口永远居中 - 琼 - 博客园 在sql server 2005数据库中更改数据架构 实现跟踪javascript代码进行调试 转摘--MS SQL Server 2000 数据库使用备份还原造成的孤立用户和对象名‘xxx’无效的错误的解决办法 转摘--具体影响Oracle系统性能的初始化参数 转摘--深入解读ADO.NET2.0的十大最新特性 实现关闭弹出页面后刷新父页 转摘——仿网易126网络硬盘上传 - 琼 - 博客园 转摘_修改表结构,让表中的字段按英文字母的顺序重新排列 javascript中获取文件后缀名 用Javascript隐藏超级链接的真实地址 UltraWebGrid模板列及行的相关操作(转) JavaScript实现DataGrid中的CheckBox全选与否 实现弹出窗口的大小 解决"当前命令发生了严重错误。应放弃任何可能产生的结果。"的问题 设置页面文字大小及颜色 图片幻灯片显示 Windows 2000 CMD命令大全
用javascript操作word文档 - 琼 - 博客园
· 2008-01-30 · via 博客园 - 琼

1、 向word中写入内容

首先在word中设置书签,如书签名为bookmark,javascript中可以这样写

var word; 
word 
= new ActiveXObject("Word.Application");
var range = word.Range;
word.Visible 
= true;
var path = "filepath";
word.Documents.Open(path);
range 
= word.ActiveDocument.Bookmarks("bookmark").Range;
range.InsertBefore(
"哈哈哈哈哈哈"); //书签后插入内容

//-----以下代码段附加保护及取消保护文档功能----

//保护文档,书签处可编辑
range.select();//选定书签内容
var psw='123'
word.ActiveDocument.BookMarks(
"bookmark").Range.Editors.Add(-1); //常量:wdEditorEveryone=-1
word.ActiveDocument.Protect(3,false,psw,false,false);//常量:wdAllowOnlyReading=3

//取消保护文档
word.ActiveDocument.Unprotect(psw);

//-----------------------end--------------

2、把word文件转成html文件

<script language=javascript>
function saveword(){
var oWordApp=new ActiveXObject("Word.Application");
var oDocument=oWordApp.Documents.Open("C:\\doc2html\\x.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>

</BODY>
</HTML>