2012-10-02 125 views
1

我在使用VBA在Word 2003中將圖片包裹在文本背後時出現問題。我可以使用所有其他包裝選項,但是當我嘗試使用wdWrapBehind時,出現以下錯誤。wdWrapBefore in word(2003)vba

「編譯錯誤:變量未定義」

我已經通過,沒有運氣谷歌此前各地追捕。

代碼:

 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 

任何幫助appreacited!

乾杯, 邁克爾

回答

1

設法得到它通過將這些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