-
All margins 0 for shapes and tables from one button
Hi John, I know you're very busy and I'm very grateful for your time in the past. I've spent a few hours trying to solve this.
I have the below code, putting two working codes together from VBA Express (great site btw!) and my efforts fail
It's to make all 4 margins in Tables AND Shapes to be 0, 0, 0, 0.
The code works separately on selected Table Cells and Selected Shapes, but I was hoping to put them into one tool.
Thanks in advance , thank you.
Code:
Sub ZeroMargins()
With ActiveWindow.Selection.ShapeRange
.TextFrame.MarginLeft = 0
.TextFrame.MarginRight = 0
.TextFrame.MarginTop = 0
.TextFrame.MarginBottom = 0
End With
Dim TBLShape As Table
Dim TBLCell As Cell
Dim iCell As Integer
Set TBLShape = ActiveWindow.Selection.ShapeRange.Table
For iCell = 1 To TBLShape.Rows.Count
For Each TBLCell In TBLShape.Rows(iCell).Cells
With TBLCell.Shape.TextFrame
.MarginTop = 0
.MarginLeft = 0
.MarginRight = 0
.MarginBottom = 0
End With
Next
Next
Set TBLCell = Nothing
Set TBLShape = Nothing
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules