简体   繁体   English

vbscript查找Word文档中存在的表数

[英]vbscript to find number of tables present in word document

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

You are so close! 你好亲密! If you didn't have a typo in your code, then this is it ( Tables , not table ): 如果您的代码中没有拼写错误,那就是它( Tables ,而不是table ):

table = wddoc.tables.Count

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM