<script language="javascript">
function outDoc(filename){
var wdapp=new ActiveXObject("Word.Application");
wdapp.visible=true;
wddoc=wdapp.Documents.Open(filename); //打开指定的文档
var myElement;
var numberOfControls=document.test.length;
for(var i=0;i<numberOfControls;i++)
{
myElement=document.test[i];
if(myElement.type=="checkbox")
{
if(myElement.checked==true)
{
if(myElement.value=="船舶"){
wdapp.Selection.GoTo(-1,0,0,"船舶");
wdapp.Selection.InsertSymbol(-3843,"Wingdings",true);
}
if(myElement.value=="海洋工程"){
wdapp.Selection.GoTo(-1,0,0,"海洋工程");
wdapp.Selection.InsertSymbol(-3843,"Wingdings",true);
}
if(myElement.value=="船用产品"){
wdapp.Selection.GoTo(-1,0,0,"船用产品");
wdapp.Selection.InsertSymbol(-3843,"Wingdings",true);
}
if(myElement.value=="ISM认证"||myElement.value=="ISPS认证"){
wdapp.Selection.GoTo(-1,0,0,"ISMISPS认证");
wdapp.Selection.InsertSymbol(-3843,"Wingdings",true);
}
}else{
var certifyCount=1;
if(myElement.value=="船舶"){
wdapp.Selection.GoTo(-1,0,0,"船舶");
wdapp.Selection.InsertSymbol(-3985,"Wingdings",true);
}
if(myElement.value=="海洋工程"){
wdapp.Selection.GoTo(-1,0,0,"海洋工程");
wdapp.Selection.InsertSymbol(-3985,"Wingdings",true);
}
if(myElement.value=="船用产品"){
wdapp.Selection.GoTo(-1,0,0,"船用产品");
wdapp.Selection.InsertSymbol(-3985,"Wingdings",true);
}
if(myElement.value=="ISM认证"||myElement.value=="ISPS认证"){
certifyCount=certifyCount-1;
if(certifyCount==1){
wdapp.Selection.GoTo(-1,0,0,"ISMISPS认证");
wdapp.Selection.InsertSymbol(-3985,"Wingdings",true);
}
}
}
}
}
//wddoc.Application.Printout();
wdapp=null;
}
这是对应的word的宏
Sub slmtest()
'
' slmtest Macro
'
Selection.GoTo What:=wdGoToBookmark, Name:="checkbox2"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.InsertSymbol Font:="Wingdings", CharacterNumber:=-3843, Unicode _
:=True
End Sub
插入的字符是一个特殊字符charmap中Wingdings中0xFD对应的字符
其中用到了word中插入选项卡中书签的作用。
本文介绍了一段用于Word文档的宏代码,该宏通过书签定位并根据选中的复选框向文档中插入特定符号。涉及的技术包括使用VBA进行Word编程、宏操作以及如何在文档中使用书签。
330

被折叠的 条评论
为什么被折叠?



