在InlineShapes之后添加段落

时间:2018-04-18 19:49:44

标签: word-vba

好吧,这可能是一个简单的问题,但我无法得到答案。我有几张照片,我相信Word会认为它们是“InlineShapes”,没有任何段落可以将它们分开;我需要在InlineShapes之间添加一个段落,这样当我去做“将文本转换为表格”时。我可以使用Paragraphs作为分色。

以下是本准则的一部分 Sub Resize()

'Resize barcodes to fit in labels
Application.ScreenUpdating = False
Dim Shap As Shape
Dim IShape As InlineShape
Dim countshapes As Long
Dim countinlineshapes As Long

'Change Images into InlineShapes
Do
    countshapes = ActiveDocument.Shapes.Count
    For Each Shap In ActiveDocument.Shapes
        Shap.ConvertToInlineShape
    Next Shap

Loop Until countshapes = 0

'Resizes the pictures(now InlineShapes) and add paragraphs
For Each IShape In ActiveDocument.InlineShapes
    With IShape
        .Width = InchesToPoints(2)
        .Height = InchesToPoints(1.2)
        .Select
    End With
    'Here is where I thought the Paragraph would be added
    Selection.Paragraphs.Add
Next IShape

'Change Page Orientation
ActiveDocument.PageSetup.Orientation = wdOrientLandscape

'Create Table

Application.ScreenUpdating = True
End Sub

由于

1 个答案:

答案 0 :(得分:0)

无需使用Select - InlineShape具有Range属性,如下所示:

Dim ilsRange as Word.Range

Set ilsRange = IShape.Range
ilsRange.InsertAfter vbCr

或者你可以缩短它,只要你不需要对范围做任何其他事情:

IShape.Range.InsertAfter vbCr
相关问题