问题
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