Thanks Paul for your prompt reply, and happy new year
Yes, the code seems correct, especially it does not return an error message but, after running, it does not change the formats specified.
However, I was lucky this time, I found a solution. I used CanvasShapes and CanvasItems collections with a variable to refer to the textboxes then apply the formats. It worked. It seems the selection object is no good here.
Just in case if anybody needs this remark, it wasted many hours of my time, here is the correct code
Code:
Dim shpCanvas As Shape
Dim shpCanvasShapes As CanvasShapes
'use to refer to each textbox inside the canvas
Dim shpCanvasTB As Shape
Set shpCanvas = ActiveDocument.Shapes("MainCanvas")
Set shpCanvasShapes = shpGridCanvas.CanvasItems
For Each shpCanvasTB In shpCanvasShapes
If shpCanvasTB.Type = msoTextBox Then
With shpCanvasTB
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
With .TextFrame
.MarginLeft = 0
.MarginRight = 0
.MarginTop = 0
.MarginBottom = 0
End With
.Select
With Selection
.Font.Size = 12
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Italic = True
End With
End With
End If
Next shpGridCanvasTB
Thanks again