繁体   English   中英

wdWrapBehind in Word(2003)vba

[英]wdWrapBehind in word (2003) vba

我在使用VBA使图片在Word 2003中的文字后面换行时遇到问题。 我可以使用所有其他包装选项,但是当我尝试使用wdWrapBehind时,出现以下错误。

“编译错误:未定义变量”

我在Google上四处搜寻,没有运气。

码:

      Dim shape1 As shape
      Dim imagePath1 As String

      imagePath1 = "C:\image.jpg"

      Set shape1 = ActiveDocument.Shapes.AddPicture(imagePath1)

      With shape1
        .ScaleHeight 1, msoTrue
        .ScaleWidth 1, msoCTrue
        .LockAspectRatio = msoTrue
        .WrapFormat.Type = wdWrapBehind
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
        .RelativeVerticalPosition = wdRelativeVerticalPositionPage
        .Left = InchesToPoints(0.433)
        .Top = InchesToPoints(0.413)
      End With

任何帮助!

干杯,迈克尔

通过添加这4行而不是wdWrapBehind设法使其正常工作。

        .WrapFormat.AllowOverlap = True
        .WrapFormat.Side = wdWrapBoth
        .WrapFormat.Type = 3
        .ZOrder 5

完整代码:

    Dim shape1 As shape         
    Dim imagePath1 As String            
    imagePath1 = "C:\image.jpg"            
    Set shape1 = ActiveDocument.Shapes.AddPicture(imagePath1)   

    With shape1
        .ScaleHeight 1, msoTrue
        .ScaleWidth 1, msoCTrue
        .WrapFormat.AllowOverlap = True
        .WrapFormat.Side = wdWrapBoth
        .LockAspectRatio = msoTrue
        .WrapFormat.Type = 3
        .ZOrder 5
        .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
        .RelativeVerticalPosition = wdRelativeVerticalPositionPage
        .Left = InchesToPoints(6.889)
        .Top = InchesToPoints(0.374)
    End With

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM