您的位置:首页 > 编程语言 > VB

如何控制IE打印中页眉和页脚

2010-12-15 11:12 363 查看
< script language="VBScript">

dim path, reg

'path存放IE打印设置的注册表地址, reg存放WScript.Shell组件的对象

path = "HKEY_CURRENT_USER/Software/Micro-soft/Internet Explorer/PageSetup"

'通过注册表修改打印设置,只修改页眉、页脚和各边界的值

'参数说明:header--页眉,footer--页脚,margin_left--左边界

'margin_top--上边界,margin_right--右边界,margin_bottom--下边界

'页边距的设置中 1对应25.4mm,即margin_left=1表示实际值的25.4mm

function pagesetup(header, footer, margin_left, margin_top, margin_right, margin_bottom)

On Error Resume Next

Set reg = CreateObject("WScript.Shell")

if err.Number>0 then

MsgBox "不能创建WScript.Shell对象!"

exit function

end if

reg.RegWrite path+"/header", header'设置页眉

reg.RegWrite path+"/footer", footer '设置页脚

reg.RegWrite path+"/margin_left", margin_left'设置左边界

reg.RegWrite path+"/margin_top", margin_top'设置上边界

reg.RegWrite path+"/margin_right", margin_right'设置右边界

reg.RegWrite path+"/margin_bottom", margin_bottom'设置下边界

end function

< /script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息