![]() |
|
#1
|
||||
|
||||
![]()
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 |
#2
|
|||
|
|||
![]()
Thanks for the response! On my side your code somehow always inserts the canvas into the paragraph that is above the paragraph that the cursor is currently in. I used "Set currentParagraphRange = Selection.Range.Paragraphs(1).Range.Next" to solve the issue but ran into errors if the current paragraph is the last paragraph in the document so there's no "Next". Is there a way to solve this?
|
![]() |
Tags |
canvas |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Determine Style of paragraph at current location | exoson | Word VBA | 2 | 01-25-2022 11:15 AM |
![]() |
laredotornado | Word | 2 | 02-22-2017 02:28 PM |
![]() |
stevec5088 | Word | 1 | 12-14-2016 02:45 PM |
![]() |
megads | Excel Programming | 2 | 07-31-2014 06:10 PM |
![]() |
Styler001 | Word | 4 | 01-25-2010 06:40 PM |