![]() |
|
|
|
#1
|
||||
|
||||
|
Try:
Code:
Sub AddImageCaptionTables()
Dim Shp As Shape, iShp As InlineShape, Rng As Range, Tbl As Table
Dim PicWdth As Single, VPos As Single, HPos As Single, VRel As Long, HRel As Long
With ActiveDocument
For Each Shp In .Shapes
With Shp
VRel = .RelativeVerticalPosition
HRel = .RelativeHorizontalPosition
VPos = .Top
HPos = .Left
PicWdth = .Width
Set iShp = .ConvertToInlineShape
End With
With iShp
Set Rng = .Range
.Range.Cut
End With
Set Tbl = .Tables.Add(Range:=Rng, Numrows:=2, NumColumns:=1)
With Tbl
With .Rows
.LeftIndent = 0
.WrapAroundText = True
.HorizontalPosition = HPos
.RelativeHorizontalPosition = HRel
.VerticalPosition = VPos
.RelativeVerticalPosition = VRel
.DistanceTop = 0
.DistanceBottom = 0
.DistanceLeft = 0
.DistanceRight = 0
.AllowOverlap = False
End With
With .Cell(1, 1).Range.ParagraphFormat
.SpaceBefore = 0
.SpaceAfter = 0
.LeftIndent = 0
.RightIndent = 0
.FirstLineIndent = 0
End With
.Cell(1, 1).Range.Paste
.Cell(2, 1).Range.Style = "Caption"
.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
.Borders(wdBorderRight).LineStyle = wdLineStyleNone
.Borders(wdBorderTop).LineStyle = wdLineStyleNone
.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
.TopPadding = 0
.BottomPadding = 0
.LeftPadding = 0
.RightPadding = 0
.Spacing = 0
.Columns.Width = PicWdth
End With
Next
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to create new word doc and save the file using String found in the document
|
VBNation | Word VBA | 2 | 02-08-2013 07:14 AM |
How to create an Excel add in that will automatically build tables from data
|
selvamariappan | Excel Programming | 1 | 12-12-2011 03:11 AM |
editing of images, tables and caption in the whole document.
|
Jamal NUMAN | Word | 4 | 07-08-2011 04:14 AM |
How to control the distance above tables as we do for images?
|
Jamal NUMAN | Word | 2 | 07-08-2011 04:09 AM |
| Help with using tables to create text. | mh11 | Word Tables | 0 | 11-15-2009 10:40 AM |