用于查找word文档中存在的表数的vbscript

时间:2014-09-04 07:37:13

标签: vbscript

Sub inserttable()

Dim wdapp
Dim wddoc
Dim strdocname
Set wdapp = CreateObject("word.application")
wdapp.Visible = True
Set wddoc = wdapp.Documents.Open("C:\Documents and Settings\dssuser.GGNS1DSS22\Desktop\sahil3.doc")
table = wddoc.table.Count
If table = 0 Then
    MsgBox ("no table found")
Else
    MsgBox ("table found")
    Exit Sub
End If
wddoc.Close
wdapp.Quit

Set wddoc = Nothing
Set wdapp = Nothing

End Sub

1 个答案:

答案 0 :(得分:0)

你真是太近了!如果你的代码中没有拼写错误,那就是它(,而不是):

table = wddoc.tables.Count