问题
I'm trying to extract text out of a document based on certain formatting rules, e.g. the font size equals 10.5. This is what I'm doing now:
Selection.Find.Font.Size = 10.5
Text = ""
Do While Selection.Find.Execute = True
Text = Text + Selection
Loop
Debug.Print Text
It works, but for some reason it doesn't seems to return all results. When I do a manual search, i.e. Ctrl+H, and use the same formatting rule many more results are returned.
What could cause this?
回答1:
In VBA +
is not used for concatenation. You have to replace it with &
Change Text = Text + Selection
to Text = Text & Selection
and try again. I have tested it and it works...
来源:https://stackoverflow.com/questions/11318016/why-is-selection-find-not-returning-all-results-in-word-vba