Moving an existing revision table to the bottom left corner on the border

Moving an existing revision table to the bottom left corner on the border

Anonymous
Not applicable
944 Views
4 Replies
Message 1 of 5

Moving an existing revision table to the bottom left corner on the border

Anonymous
Not applicable

 

On using VBA to update some drawings I have found that the revision table is not always in the correct place once they've been updated.

I would like it to be sat against the border in the bottom left corner of the drawing but can't work out how. I assumed that the MinPoint of the border and revision table would be the same but cannot get the code to work.

 

Any advice?

 

Sub AlignRevBox()

    Set invDoc = ThisApplication.ActiveDocument
    Set oRevTable = invDoc.ActiveSheet.RevisionTables.Item(1)

    Dim RevPt As Point2d
    Dim BorderPt As Point2d
    Dim oTG As TransientGeometry

    Set BorderPt = invDoc.ActiveSheet.Border.RangeBox.MinPoint
    Debug.Print BorderPt.X, BorderPt.Y
    oTG = ThisApplication.TransientGeometry
    RevPt = oTG.CreatePoint2d(BorderPt.X, BorderPt.Y)
    
    oRevTable.RangeBox.MinPoint = RevPt


End Sub
0 Likes
Accepted solutions (1)
945 Views
4 Replies
Replies (4)
Message 2 of 5

bshbsh
Collaborator
Collaborator

replace last line with this:

oRevTable.Position = RevPt

0 Likes
Message 3 of 5

Anonymous
Not applicable

I tried that and it aligned the top of the table with the bottom of the border meaning the table was outside the border. I would like the bottom left corner of the table aligned with the bottom left corner of the border.

0 Likes
Message 4 of 5

salariua
Mentor
Mentor
Accepted solution

how about this? works for me

 

Sub AlignRevBox()

    Set invDoc = ThisApplication.ActiveDocument
    Set oRevTable = invDoc.ActiveSheet.RevisionTables.Item(1)

    Dim RevPt As Point2d
    Dim BorderPt As Point2d
    Dim oTG As TransientGeometry

    Set BorderPt = invDoc.ActiveSheet.Border.RangeBox.MinPoint

    'Debug.Print BorderPt.X, BorderPt.Y
    Set oTG = ThisApplication.TransientGeometry
    Set RevPt = oTG.CreatePoint2d(BorderPt.X, BorderPt.Y + (oRevTable.RangeBox.MaxPoint.Y - oRevTable.RangeBox.MinPoint.Y))

    oRevTable.Position = RevPt

End Sub
Adrian S.
blog.ads-sol.com 

AIP2012-2020 i7 6700k AMD R9 370
Did you find this reply helpful ?
If so please use the Accepted Solutions or Like button - Thank you!
Message 5 of 5

Anonymous
Not applicable

Ah yes thank you, that does make sense.

0 Likes