请参:
'* +++++++++++++++++++++++++++++++++++++++
'* Created By 守柔@ExcelHome 2004-12-06 17:39:07
'仅测试于System: Windows NT Word: 10.0 Language: 2052
'^The Code CopyIn [ThisDocument-ThisDocument]^'
'* --------------------------------------------------------------------------
Private Sub Document_Open()
With ActiveDocument.PageSetup
If .TopMargin <> CentimetersToPoints(1.5) Then MsgBox "上边距错误!"
If .BottomMargin <> CentimetersToPoints(1.5) Then MsgBox "下边距错误!"
If .LeftMargin <> CentimetersToPoints(1) Then MsgBox "左边距错误!"
If .RightMargin <> CentimetersToPoints(1) Then MsgBox "右边距错误!"
If .PaperSize <> wdPaperA3 Then MsgBox "纸型设置错误"
End With
End Sub
'---------------------- 注意该代码粘贴于全局模板的THISDOCUMENT代码窗口中.
注意二:受数据类型的影响,会出现转换后的厘米数据与实现页面设置不一致,请楼主录个宏(页面设置),然后用MSGBOX 返回相应页边距,用以取代CentimetersToPoints(?)这个值.
比如上边距1.5厘米,在WORD中的返回值为42.55(MsgBox ActiveDocument.PageSetup.TopMargin)=42.55
,而msgbox CentimetersToPoints(1.5)=42.51968,当然上述代码仍然会出错误的对话框.
[此贴子已经被作者于2004-12-6 18:51:56编辑过] |