I'm working with many InlineShapes and need to move them around the document.
Getting the Range they're anchored to and changing it (e.g. modifying "Start"
and "End" properties) doesn't seem to have any effect.

I can, in the Word document, cut and paste an InlineShape (thus moving it).
However, you have to select, in addition to the InlineShape, a character
before it or after it for the selection to "appear" and for you to be able to
cut it.

If I access the Range of the InlineShape programmatically and try and select
it or cut it, nothing happens. If I grow the range by a character, I _can_
select that, and then cut it. A hack way of moving the InlineShape is to
insert some whitespace before or after the InlineShape, select it, cut it,
and delete the whitespace on pasting.

Is there a less circuitous way of moving the InlineShape around in the
document?

(I realize, besides cutting and pasting, I can also use Range.Move() to move
it)

Someone in this thread mentioned the Shape.Range.Position property, which
VSTO doesn't expose apparently.
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.word.vba.general&tid=3dc224a4-d650-42b5-abf0-22973b0878d6&cat=en-us-msdn-officedev-word&lang=en&cr=US&sloc=en-us&m=1&p=1

I posted this question previously in the VSTO forum, but they suggested I
come here.

Thanks

Re: Is it possible to change the position of an InlineShape? by Jezebel

Jezebel
Tue Mar 07 01:34:29 CST 2006

Use a Shape instead of an InlineShape. That's the whole point of the
difference: Shapes are floating and can be positioned anywhere on the page
that contains the anchor.



"Phil Crosby" <Phil Crosby@discussions.microsoft.com> wrote in message
news:FA20CC12-5A06-42C6-B88F-536173DA1B0F@microsoft.com...
> I'm working with many InlineShapes and need to move them around the
> document.
> Getting the Range they're anchored to and changing it (e.g. modifying
> "Start"
> and "End" properties) doesn't seem to have any effect.
>
> I can, in the Word document, cut and paste an InlineShape (thus moving
> it).
> However, you have to select, in addition to the InlineShape, a character
> before it or after it for the selection to "appear" and for you to be able
> to
> cut it.
>
> If I access the Range of the InlineShape programmatically and try and
> select
> it or cut it, nothing happens. If I grow the range by a character, I _can_
> select that, and then cut it. A hack way of moving the InlineShape is to
> insert some whitespace before or after the InlineShape, select it, cut it,
> and delete the whitespace on pasting.
>
> Is there a less circuitous way of moving the InlineShape around in the
> document?
>
> (I realize, besides cutting and pasting, I can also use Range.Move() to
> move
> it)
>
> Someone in this thread mentioned the Shape.Range.Position property, which
> VSTO doesn't expose apparently.
> http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.word.vba.general&tid=3dc224a4-d650-42b5-abf0-22973b0878d6&cat=en-us-msdn-officedev-word&lang=en&cr=US&sloc=en-us&m=1&p=1
>
> I posted this question previously in the VSTO forum, but they suggested I
> come here.
>
> Thanks
>



Re: Is it possible to change the position of an InlineShape? by PhilCrosby

PhilCrosby
Tue Mar 07 08:08:31 CST 2006

For my purposes, InlineShape is the right choice. I want the anchor to exist
at the character level, not the paragraph level.

Whether InlineShape or Shape is used, both should provide the ability to be
repositioned.



"Jezebel" wrote:

> Use a Shape instead of an InlineShape. That's the whole point of the
> difference: Shapes are floating and can be positioned anywhere on the page
> that contains the anchor.


Re: Is it possible to change the position of an InlineShape? by Jay

Jay
Tue Mar 07 15:46:24 CST 2006

An InlineShape behaves like a single character. It doesn't have a
"position", it simply has a location in the sequence of characters. That's
why you can't reposition it.

You can do something like this, though:

Sub MoveInlineShape()
' Move the first InlineShape object
' from its current position to the end
' of the following paragraph.

Dim ils As InlineShape
Dim rgIls As Range
Dim rgDest As Range

Set ils = ActiveDocument.Range.InlineShapes(1)
Set rgIls = ils.Range

Set rgDest = rgIls.Paragraphs(1).Next.Range
With rgDest
.Collapse wdCollapseEnd
' rgDest is now at the start of the
' paragraph after the one we want, so
' move back one char
.Move unit:=wdCharacter, Count:=-1
.FormattedText = rgIls.FormattedText
End With

rgIls.Delete

Set rgIls = Nothing
Set rgDest = Nothing
Set ils = Nothing
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Phil Crosby wrote:
> For my purposes, InlineShape is the right choice. I want the anchor
> to exist at the character level, not the paragraph level.
>
> Whether InlineShape or Shape is used, both should provide the ability
> to be repositioned.
>
>
>
> "Jezebel" wrote:
>
>> Use a Shape instead of an InlineShape. That's the whole point of the
>> difference: Shapes are floating and can be positioned anywhere on
>> the page that contains the anchor.



Re: Is it possible to change the position of an InlineShape? by PhilCrosby

PhilCrosby
Tue Mar 07 23:40:26 CST 2006

What I mean by position is the location in the sequence of characters. Seems
we're equivocating on "position" vs. "location."

Collapsing the Range of the InlineShape I'm using has no effect. Maybe it's
because it's an ActiveX control... cutting and then pasting the shape in the
desired location has the same effect, and that seems to be working out great.

Thanks Jay.

-Phil Crosby

"Jay Freedman" wrote:

> An InlineShape behaves like a single character. It doesn't have a
> "position", it simply has a location in the sequence of characters. That's
> why you can't reposition it.
>
> You can do something like this, though:
>
> Sub MoveInlineShape()
> ' Move the first InlineShape object
> ' from its current position to the end
> ' of the following paragraph.
>
> Dim ils As InlineShape
> Dim rgIls As Range
> Dim rgDest As Range
>
> Set ils = ActiveDocument.Range.InlineShapes(1)
> Set rgIls = ils.Range
>
> Set rgDest = rgIls.Paragraphs(1).Next.Range
> With rgDest
> .Collapse wdCollapseEnd
> ' rgDest is now at the start of the
> ' paragraph after the one we want, so
> ' move back one char
> .Move unit:=wdCharacter, Count:=-1
> .FormattedText = rgIls.FormattedText
> End With
>
> rgIls.Delete
>
> Set rgIls = Nothing
> Set rgDest = Nothing
> Set ils = Nothing
> End Sub
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.


Re: Is it possible to change the position of an InlineShape? by Jezebel

Jezebel
Wed Mar 08 21:48:21 CST 2006

You can apply character positioning, like raised or lowered, if that's the
kind of positioning you have in mind.


"Phil Crosby" <PhilCrosby@discussions.microsoft.com> wrote in message
news:496CD740-AAB0-4EC7-AFFC-5D68042E297F@microsoft.com...
> For my purposes, InlineShape is the right choice. I want the anchor to
> exist
> at the character level, not the paragraph level.
>
> Whether InlineShape or Shape is used, both should provide the ability to
> be
> repositioned.
>
>
>
> "Jezebel" wrote:
>
>> Use a Shape instead of an InlineShape. That's the whole point of the
>> difference: Shapes are floating and can be positioned anywhere on the
>> page
>> that contains the anchor.
>