Image alignment disturbs in Pastespecial

A

anand

Hello Group
I am converting all EMFs of a word document into GIF using Paste special
Selection.PasteSpecial Link:=False, DataType:=13, Placement:= _
wdFloatOverText, DisplayAsIcon:=False
The probelm is that after allignment it disturbs the aligmant of images and
by default it takes left.
Has any one any idea how i can persist the alignment.

Thanks

Anand
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < anand > écrivait :
In this message, < anand > wrote:

|| Hello Group
|| I am converting all EMFs of a word document into GIF using Paste special
|| Selection.PasteSpecial Link:=False, DataType:=13, Placement:= _
|| wdFloatOverText, DisplayAsIcon:=False
|| The probelm is that after allignment it disturbs the aligmant of images
and
|| by default it takes left.
|| Has any one any idea how i can persist the alignment.
||

I think we need more details here...
I.ll go out on a limb here...
You mention an alignment that is disturbed in some way. Are you talking
about the new picture's alignment? If so,
Placement:= wdFloatOverText
in your code will not necessarily mean that the new picture will be wrapped
in the same way as the original one was.
You have to record the original picture parameters before cutting it.

Play around with the following code to get an idea of how it works. Just
select a picture and run the code.

'_______________________________________
Dim MyPix As Shape
Dim MyRange As Range
Dim PixWrap As Long
Dim PixWrapSide As Long
Dim PixTop As Long
Dim PixLeft As Long

With Selection.ShapeRange
With .WrapFormat
PixWrap = .Type
PixWrapSide = .Side
End With
PixTop = .Top
PixLeft = .Left
End With

Selection.Cut

Set MyRange = Selection.Range

MyRange.PasteSpecial Link:=False, DataType:=13, Placement:= _
wdFloatOverText, DisplayAsIcon:=False

Set MyPix = MyRange.ShapeRange(1)

With MyPix
With .WrapFormat
.Type = PixWrap
.Side = PixWrapSide
End With
.Left = PixLeft
.Top = PixTop
End With

MyPix.Select

Set MyPix = Nothing
Set MyRange = Nothing
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

anand

Jean

If I select a picture, it works perfectly, but If I run on whole
document(having 45 pages with 1 or 2 iamge on each page), its postion get
disturbed. Here is the code, let me know what wrong I am doing?

*-------------------------
Dim MyPix As Shape
Dim MyRange As Range
Dim PixWrap As Long
Dim PixWrapSide As Long
Dim PixTop As Long
Dim PixLeft As Long
Dim s

For Each s In ActiveDocument.Shapes
If s.Type = msoPicture Then
s.Select
With Selection.ShapeRange
With .WrapFormat
PixWrap = .Type
PixWrapSide = .Side
End With
PixTop = .Top
PixLeft = .Left
End With

Selection.Cut

Set MyRange = Selection.Range

MyRange.PasteSpecial Link:=False, DataType:=13, Placement:= _
wdFloatOverText, DisplayAsIcon:=False

Set MyPix = MyRange.ShapeRange(1)

With MyPix
With .WrapFormat
.Type = PixWrap
.Side = PixWrapSide
End With
.Left = PixLeft
.Top = PixTop
End With

MyPix.Select

Set MyPix = Nothing
Set MyRange = Nothing


End If
Next s
End Sub
*-------------------------
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < anand > écrivait :
In this message, < anand > wrote:

|| Jean
||
|| If I select a picture, it works perfectly, but If I run on whole
|| document(having 45 pages with 1 or 2 iamge on each page), its postion get
|| disturbed. Here is the code, let me know what wrong I am doing?
||

The following worked for me on a document with 2 pages and 4 pictures:

'_______________________________________
Sub Test()

Dim MyPix As Shape
Dim PastedPix As Shape
Dim MyRange As Range
Dim PixWrap As Long
Dim PixWrapSide As Long
Dim PixTop As Long
Dim PixLeft As Long

Set MyRange = Selection.Range

For Each MyPix In ActiveDocument.Range.ShapeRange

If MyPix.Type = msoPicture Then

With MyPix
With .WrapFormat
PixWrap = .Type
PixWrapSide = .Side
End With
PixTop = .Top
PixLeft = .Left
.Select
End With

Selection.Cut

Selection.PasteSpecial Link:=False, DataType:=13, Placement:= _
wdFloatOverText, DisplayAsIcon:=False
Set PastedPix = Selection.ShapeRange(1)

With PastedPix
With .WrapFormat
.Type = PixWrap
.Side = PixWrapSide
End With
.Left = PixLeft
.Top = PixTop
End With

Set PastedPix = Nothing

End If
Next MyPix

MyRange.Select

Set MyRange = Nothing

End Sub
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

anand

Hello Bonjour, Thanks alot , it has solved problem to certain extent.
Actuallu when we cut that image with
selection.cut
the Texts that follow image moves up imidiately and affects the alignment.I
am trying for it. what do you say?
Anand
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < anand > écrivait :
In this message, < anand > wrote:

|| Hello Bonjour, Thanks alot , it has solved problem to certain extent.
|| Actuallu when we cut that image with
|| selection.cut
|| the Texts that follow image moves up imidiately and affects the
alignment.I
|| am trying for it. what do you say?

I say "No problem"!
Because when you paste the image back to the exact same location with the
same wrapping, the text goes back to where it was. At least, on my machine,
that is what happens. So I do hot understand you having a problem with the
text moving.... Or are you stopping the code before the paste is done?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

anand

Hello there, yah you got my problem wright way.I am still having problem.
how can I stop code b4 paste is done as when it cuts the image texts
automatically move up.Looking for more work arounds.

Rgds
Anand


----- Original Message -----
From: "Jean-Guy Marcil" <[email protected]>
Newsgroups:
microsoft.public.vb.general.discussion,microsoft.public.word.conversions,mic
rosoft.public.word.docmanagement,microsoft.public.word.formatting.longdocs,m
icrosoft.public.word.vba.general
Sent: Monday, May 31, 2004 12:01 AM
Subject: Re: Image alignment disturbs in Pastespecial
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < anand > écrivait :
In this message, < anand > wrote:

|| Hello there, yah you got my problem wright way.I am still having problem.
|| how can I stop code b4 paste is done as when it cuts the image texts
|| automatically move up.Looking for more work arounds.
||

I still do not get it.
Why would you want to stop the code before the past action?

And, whenever you cut something, the text will always move to fill the space
previously occupied by the object that was cut. Unless you paste something
back in its place...

So, I do not understand your problem. You wanted to take a picture, cut it
out and paste it back in a different format with PasteSpecial. The code I
posted does just that. Why are you still having problems? If you have
changed your requirement or goal along the line, you have not explicitly
written about it, or I totally missed out on something.

Sorry. If you still need help, you are going to have to be more explicit.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

anand

Bonjour ,
My problem was that after Pasting the image back to its place the texts
were not moving to right place so was creating problem.Anyways now cheers we
got the perfect macro does not disturb any thing what so ever.Thanks for
your throughout support,

Regards
Anand
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < anand > écrivait :
In this message, < anand > wrote:

|| Bonjour ,
|| My problem was that after Pasting the image back to its place the texts
|| were not moving to right place so was creating problem.Anyways now cheers
we
|| got the perfect macro does not disturb any thing what so ever.Thanks for
|| your throughout support,
||
|| Regards
|| Anand

Glad you sorted things out!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < anand > écrivait :
In this message, < anand > wrote:

|| Thanks you .By the way where are you from.

Montreal, why?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

anand

Jus like that, any ways, well that code is working fine with 2003 , not with
2000, initially i thought it might be problem of libraries as 2000 uses
microsoft office 9.0 object liabrary and 2003 uses version 11.0, but it
surprisingly it works when we debug with Key F8.
have been lookin for some work around .any suggestion , here is the code.
-----------------------------
sub Convert()

Dim MyPix As Shape
Dim PastedPix As Shape
Dim MyRange As Range
Dim PixWrap As Long
Dim PixWrapSide As Long
Dim PixTop As Long
Dim PixLeft As Long

Set MyRange = Selection.Range

For Each MyPix In ActiveDocument.Range.ShapeRange

If MyPix.Type = msoPicture Then

With MyPix
With .WrapFormat
PixWrap = .Type
PixWrapSide = .Side
End With
PixTop = .Top
PixLeft = .Left
.Select
End With

Selection.Cut

Selection.PasteSpecial Link:=False, DataType:=13, Placement:= _
wdFloatOverText, DisplayAsIcon:=False
Set PastedPix = Selection.ShapeRange(1)
With PastedPix
With .WrapFormat
.Type = wdWrapTight
.Side = PixWrapSide
.AllowOverlap = msoFalse
End With

.LockAnchor = msoFalse
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.Top = InchesToPoints(1.75)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionColumn
.Left = PixLeft
.Top = PixTop
End With

Set PastedPix = Nothing

End If
Next MyPix

MyRange.Select

Set MyRange = Nothing

end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top