I open a document, and would like to travel and set all paragraghs with bold.
this is the code
for each par in activedocument.paragraphs:
par.range.bold=true
next
After I run this code,I found paragraphs in textbox not be changed.
So,how to travel all paragraphs in a document with vba
This should work for the text boxes, because they are not paragraph objects.
Dim shp As Shape
For Each shp In ActiveDocument.Shapes
ActiveDocument.Shapes.Range(Array(shp.Name)).Select
Selection.Font.Bold = True
Next
There are probably other ways too.
That is the WRONG way to format a document. All you need do is format the relevant paragraph Styles with the bold attribute. For example:
ActiveDocument.Styles(wdStyleNormal).Font.Bold = True
Then it doesn't matter whether the content is in the document body, a header or footer, a footnote or endnote, or in a textbox in any of those ranges.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.