R
Robbie
I thought I'd feed this back to the newsgroup, since it
took so long to work out, maybe someone else can benefit.
I'm was in Word 2000, halfway thru a macro that 'cuts' a
bitmap graphic, then pastes the graphic back
(Edit|Paste_Special|Paste_as_Picture) as a "picture".
I wanted to select what has just been pasted, and then do
further action on it, eg move it into place.
What I couldn't work out was the code needed to select the
picture again once it had been pasted into the document.
Word numbers each graphic (eg "Picture 3"), but I couldn't
use that to select it because the numbers may change.
Recording my actions gave me a macro something like
Sub MacroImageMove()
' ImageMove Macro
Selection.Cut
Selection.PasteSpecial Link:=False, _
DataType:=wdPasteMetafilePicture, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
ActiveDocument.Shapes("Picture 3").Select
'What can I use instead of the previous line(s)?
End Sub
The problem had something to do with the difference
between wdFloatOverText and wdInLine (neither of which can
I find an explanation for). But I still didn't know to
select it!
So this is the final answer.
Sub MacroImageMove()
' I want to select the image, then run the macro from the
toolbar so that
' it cuts the graphic and pastes it back as a "picture"
(smaller file size).
' Then I can move it to the right of the page, top of the
line, or else as necessary.
' The problem I faced was how to select the picture that
has just been pasted,
' rather than eg the specific "Picture 3".
Selection.Cut
Selection.PasteSpecial Link:=False,
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine,
DisplayAsIcon:=False 'Not wdFloatOverText
' ActiveDocument.Shapes("Picture 3").Select 'this is the
line that was problem
Selection.Extend
Selection.MoveLeft
Selection.InlineShapes(1).Select
Selection.InlineShapes(1).ConvertToShape
With Selection.ShapeRange
.Line.Visible = msoFalse
.RelativeHorizontalPosition =
wdRelativeHorizontalPositionMargin
.RelativeVerticalPosition =
wdRelativeVerticalPositionLine
.Left = wdShapeRight
.Top = wdShapeTop
.LockAnchor = False
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapLeft
.WrapFormat.DistanceTop = CentimetersToPoints(0)
.WrapFormat.DistanceBottom = CentimetersToPoints(0)
.WrapFormat.DistanceLeft = CentimetersToPoints(0.1)
.WrapFormat.DistanceRight = CentimetersToPoints
(0.1)
.WrapFormat.Type = wdWrapTight
End With
End Sub
Not elegant, but what code is with VBA?
NB The text is too wide & has got wrapped in this post.
Hope this helps someone else.
Robbie
took so long to work out, maybe someone else can benefit.
I'm was in Word 2000, halfway thru a macro that 'cuts' a
bitmap graphic, then pastes the graphic back
(Edit|Paste_Special|Paste_as_Picture) as a "picture".
I wanted to select what has just been pasted, and then do
further action on it, eg move it into place.
What I couldn't work out was the code needed to select the
picture again once it had been pasted into the document.
Word numbers each graphic (eg "Picture 3"), but I couldn't
use that to select it because the numbers may change.
Recording my actions gave me a macro something like
Sub MacroImageMove()
' ImageMove Macro
Selection.Cut
Selection.PasteSpecial Link:=False, _
DataType:=wdPasteMetafilePicture, _
Placement:=wdFloatOverText, DisplayAsIcon:=False
ActiveDocument.Shapes("Picture 3").Select
'What can I use instead of the previous line(s)?
End Sub
The problem had something to do with the difference
between wdFloatOverText and wdInLine (neither of which can
I find an explanation for). But I still didn't know to
select it!
So this is the final answer.
Sub MacroImageMove()
' I want to select the image, then run the macro from the
toolbar so that
' it cuts the graphic and pastes it back as a "picture"
(smaller file size).
' Then I can move it to the right of the page, top of the
line, or else as necessary.
' The problem I faced was how to select the picture that
has just been pasted,
' rather than eg the specific "Picture 3".
Selection.Cut
Selection.PasteSpecial Link:=False,
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine,
DisplayAsIcon:=False 'Not wdFloatOverText
' ActiveDocument.Shapes("Picture 3").Select 'this is the
line that was problem
Selection.Extend
Selection.MoveLeft
Selection.InlineShapes(1).Select
Selection.InlineShapes(1).ConvertToShape
With Selection.ShapeRange
.Line.Visible = msoFalse
.RelativeHorizontalPosition =
wdRelativeHorizontalPositionMargin
.RelativeVerticalPosition =
wdRelativeVerticalPositionLine
.Left = wdShapeRight
.Top = wdShapeTop
.LockAnchor = False
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapLeft
.WrapFormat.DistanceTop = CentimetersToPoints(0)
.WrapFormat.DistanceBottom = CentimetersToPoints(0)
.WrapFormat.DistanceLeft = CentimetersToPoints(0.1)
.WrapFormat.DistanceRight = CentimetersToPoints
(0.1)
.WrapFormat.Type = wdWrapTight
End With
End Sub
Not elegant, but what code is with VBA?
NB The text is too wide & has got wrapped in this post.
Hope this helps someone else.
Robbie