Hi! I simply want to insert a canvas as an inline at the current location of my cursor but my code keeps inserting it at the 1st paragraph of a page. Below attached my code:
Code:
Sub InsertCanvas()
Dim shpCanvas As Shape
Dim CanvasWidth As Double
Dim CanvasHeight As Double
Dim currentParagraph As Paragraph
Call FigureTools.ExitCompatibilityMode 'Exit the compatibility mode
' Get the current paragraph
Set currentParagraph = Selection.Range.Paragraphs(1)
CanvasWidth = 450
CanvasHeight = 252
' Add a drawing canvas to the active document at the current paragraph
Set shpCanvas = ActiveDocument.Shapes.AddCanvas(Left:=100, Top:=75, Width:=CanvasWidth, Height:=CanvasHeight, Anchor:=currentParagraph.Range)
With shpCanvas
.WrapFormat.Type = wdWrapInline
.Visible = msoTrue
End With
End Sub
According to the documentation, the Anchor of AddCanvas() is "A Range object that represents the text to which the canvas is bound. If Anchor is specified, the anchor is positioned at the beginning of the first paragraph in the anchoring range. If this argument is omitted, the anchoring range is selected automatically and the canvas is positioned relative to the top and left edges of the page." I don't understand as AddCanvas seems to ignore the Anchor I provided. Could someone give some suggestions on how to fix this? Thanks!