Javascript实例教程(20-7)
作者: 来源: 添加时间:2006-5-25 18:15:22
(图1)
现在假设你想格式化文档中所选择的部分。这个请求的宏(称为Format Current Selection)跟上面所述的宏(Format Current Document)很类似。它们之间的不同只是在:Format Current Document中 Layout()方法是操作ActiveDocument 对象,而Format Current Selection中 Layout()方法是操作Selection对象:
<MACRO name="Format Current Selection" lang="JScript" id="53" desc="Apply source layout to the current selection">
<![CDATA[
if (ActiveDocument.ViewType == viewSource) {
Selection.Layout();
} else{
Application.Alert("Applying source layout only works in source view.\nSwitch to source view and try again.");
}
]]></MACRO>
站内搜索