Need Script to Ignore MSword tables - probably a simple issue with syntax

ぐ巨炮叔叔 提交于 2019-12-13 03:56:31

问题


I have issues with my code dealing with tables, specifically I want the code to ignore them. I do not want this code to apply to tables so I thouht that I'd use "Selection.Information(wdWithInTable) = False" to clear things up. Unfortunately I don't know how to select the paragraph that the script is currently working.

I tried putting Selection.Paragraphs(i).Range.Select in at the **** but that didn't eliminate working with the first row of a table and I don't know why. I'm new to VBA and syntax in general so I'm assuming that's the issue.

Dim prePara As Paragraph
Dim curPara As Paragraph
Dim nextPara As Paragraph

For i = 2 To ActiveDocument.Paragraphs.Count

    Set prePara = ActiveDocument.Paragraphs(i - 1)
    Set curPara = ActiveDocument.Paragraphs(i)


    If curPara.LeftIndent <= prePara.LeftIndent And curPara.Style = "Normal" Or curPara.Style = "List Paragraph" Then

        ***** 'here is where I tried Selection.Paragraphs(n).Range.Select but it didn't work
        If Selection.Information(wdWithInTable) = False Then
            If curPara.LeftIndent < prePara.LeftIndent Then
                curPara.LeftIndent = prePara.LeftIndent
            End If
        End If
    End If
Next

回答1:


With this statement:

Selection.Paragraphs(i).Range.Select

you are trying to Select a Selection object.

Try:

ActiveDocument.Paragraphs(i).Range.Select


来源:https://stackoverflow.com/questions/23633209/need-script-to-ignore-msword-tables-probably-a-simple-issue-with-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!