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

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - 琼

服务器 '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>