View Single Post
 
Old 06-04-2023, 07:23 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,166
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I think you need to position the canvas at the location of the selected paragraph before setting it to inline.
Code:
Sub InsertCanvas2()
  Dim shpCanvas As Shape, CanvasWidth As Double, iTop As Integer, iLeft As Integer
  Dim CanvasHeight As Double, aRng As Range
    
  'Call FigureTools.ExitCompatibilityMode 'Exit the compatibility mode
  
  ' Get the current paragraph
  Set aRng = Selection.Range.Paragraphs(1).Range
  iTop = aRng.Information(wdVerticalPositionRelativeToPage)
  iLeft = aRng.Information(wdHorizontalPositionRelativeToPage)
  CanvasWidth = 450
  CanvasHeight = 252
  
  ' Add a drawing canvas to the active document at the current paragraph
  Set shpCanvas = ActiveDocument.Shapes.AddCanvas(Left:=iLeft, Top:=iTop, Width:=CanvasWidth, Height:=CanvasHeight, Anchor:=aRng)
  
  With shpCanvas
    '.Fill.ForeColor.RGB = RGB(24, 100, 30)
    .WrapFormat.Type = wdWrapInline
    .Visible = msoTrue
  End With
    
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote