Selecting Inlineshape after PasteAndFormat

H

Hans Troost

L.S.
Due to demo of an application I have to replace about 10.000
inlineshapes (special type, ISIS/Draw)
in 4000 Word doc's by inlineshapes randomly selected from a an example
Database with these drawings.

Problem: it is easy to replaCe the Inlineshape (always the first and
only one withing a Bookmark)
but I seem to be unable to select it again after replacing after
replacing. And that is what I need
to restore the bookmark.
Can someone help me out?

I'm using WordXP (also called Word 2002)

Here's my code:

Sub ReplaceSketchInDoc(ActiveDoc As Document, BM As String, SkType As
enumSketch_Type)

Dim iShp As InlineShape
Dim rgPlace As Range
Dim ScaleFactor As Single
Dim OldWidth As Long
Dim NewWidth As Long
Dim OldHeight As Long
Dim NewHeight As Long

On Error GoTo Error_ReplaceSketchInDoc

Set rgPlace = ActiveDoc.Bookmarks(BM).Range


' insert the Sketch file from the clipboard after creation with
CreateSketchFile)
Call CreateSketchFile(SkType)
With rgPlace.InlineShapes(1)
.Select
.Range.PasteAndFormat (wdFormatOriginalFormatting)
End With
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! till here: everything is going fine, but
! the next statement goes wrong
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Set ihsp = Selection ! this does not work, there seems to be no
selection!!!
' make sure bookmark covers sketch
ActiveDoc.Bookmarks.Add Name:=BM, Range:=iShp.Range

Exit_ReplaceSketchInDoc:
Exit Sub

Error_ReplaceSketchInDoc:
Call Err.Raise(Err.Number, "ReplaceSketchInDoc", Err.Description)
Resume Exit_ReplaceSketchInDoc

End Sub


Thanks in advance,

Hans Troost
 
H

Helmut Weber

Hi Hans,
without pondering much about an otherwise maybe interesting
question, this seems odd to me:
Dim iShp As InlineShape
Set ihsp = Selection
Do you see it?
 
H

Hans Troost

Helmut Weber said:
Hi Hans,
without pondering much about an otherwise maybe interesting
question, this seems odd to me:
Do you see it?
---
Yes,
I see it: thanks, stupid error which I overlooked all the time,
but.... still this does not solve the problem. The real problem is
that after
With rgPlace.InlineShapes(1)
.Select
.Range.PasteAndFormat (wdFormatOriginalFormatting)
End With
the selection is gone!!, despite the .select.
How to re-select the thus changed inlineshape?

Hans
 
H

Hans Troost

Helmut Weber said:
Hi Hans,
without pondering much about an otherwise maybe interesting
question, this seems odd to me:
Do you see it?
---
Yes,
I see it: thanks, stupid error which I overlooked all the time,
but.... still this does not solve the problem. The real problem is
that after
With rgPlace.InlineShapes(1)
.Select
.Range.PasteAndFormat (wdFormatOriginalFormatting)
End With
the selection is gone!!, despite the .select.
How to re-select the thus changed inlineshape?

Hans
 
H

Helmut Weber

Hi Hans,
that the selection is the insertion point
after pasting whatever, seems to be Word's
regular behaviour, even with ordinary text.
If there was only one inlineshape in the bookmark's
range and nothing but the inlineshape, then
simply extending the selection to the right
should do the job.
Like this:

With Selection
.InlineShapes(1).Select
.Range.PasteAndFormat (wdFormatOriginalFormatting)
.ExtendMode = True
.MoveRight
End With
---
restore the bookmark using selection.range
and reset extendmode
---

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
Top