Chinaunix

标题: 如何用vba控制word 表格内容必须不为空 [打印本页]

作者: renxiao2003    时间: 2011-12-21 08:41
标题: 如何用vba控制word 表格内容必须不为空
  1. Public WithEvents App As Word.Application

  2. Private Sub App_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)

  3. With Doc.Tables(1)

  4. For Each c In .Range.Cells
  5. If Len(c.Range) <= 3 Then

  6. a = MsgBox("表格填写不完整,确定要退出吗?", vbYesNo)
  7. If a = vbNo Then
  8. Cancel = True
  9. c.Range.Select
  10. End If
  11. Exit For

  12. End If
  13. Next

  14. End With

  15. End Sub





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2