Jean-Guy
Fri Dec 16 10:36:14 CST 2005
Piou2fois was telling us:
Piou2fois nous racontait que :
> Thank for the shape, i do not use shape in my word document, so i did
> not transform them :)
So, in your original post, what did you mean by:
"-paste as something which is not inlineshape (picture is in edit mode)"
Weren't you referring to floating pictures? If so, those are shapes, not
inlineshapes.
If you meant selecting an inline shape and pasting it as a floating one,
then I am sorry, I misunderstood your question.
Change the value of the Placement argument in:
Selection.PasteSpecial Link:=False, _
DataType:=15, _
Placement:=wdInLine
so as to have:
Selection.PasteSpecial Link:=False, _
DataType:=15, _
Placement:=wdFloatOverText
and remove the first loop.
> Just for copy and delete, you can cut
> Selection.CopyAsPicture
> Selection.Delete
> ->
> Selection.Cut
I am a bit confused by that.
In your original post, you posted the following code:
Selection.CopyAsPicture
Selection.PasteSpecial Link:=False, _
DataType:=15, _
Placement:=wdInLine
cut_paste_as_jpg = True
I just pointed out that on my machine, this code left the original picture
in the document, which seemed to go against your intention with the code
(This same code did not leave the original picture in the document on your
machine?).
So I suggested the following code just to stay as close as possible to your
original post:
Selection.CopyAsPicture
Selection.Delete
Selection.PasteSpecial Link:=False, _
DataType:=15, _
Placement:=wdInLine
cut_paste_as_jpg = True
If you knew all along that:
Selection.CopyAsPicture
Selection.Delete
can be replaced by
Selection.Cut
why did you not use it?
> I stille have the black border below and right of the picture, inside
> the picture, so if i transform the picture 10times i will have big
> black border on my pictures...
Remember also that by forcing the jpg format on the picture, Word as to
convert it from whatever format it was before. For example, if I run your
code with a GIF that had a transparent background, the resulting picture
will look very different as the JPG format does not support the
transparency. In fact, chances are that the background will become black. So
you maybe running into something like this.
Finally, keep in mind that by using 15 as a datatype (JPG) your are forcing
Word to insert a jpg, which it does not normally do. Word is not a good
picture handler. To see what I mean, run your code and then do ALT-F9 in
your document. You will see a bunch of {SHAPE \* MERGEFORMAT} in lieu of
the pictures. This is a very difficult beast to handle that leads to all
kinds of problems. One problem is that as a field it will not be pasted
"floating", so the "wdFloatOverText " I suggested earlier will not work with
15 as a datatype. If you manually convert the picture to floating, it will
work.
So, you could try using this
For Each pix In ActiveDocument.Shapes
pix.WrapFormat.Type = wdWrapNone
Next
at the end of the code, just before the
StartRange.Select
line.
But you will have the positioning problem instead....
So, there might be a better approach that is altogether very different to
the one you are attempting now.
If you want to ask about that, I would suggest that you start a new thread
explaining your goal, the type of content in the document, what you have
tried so far and the problems you have encountered.
Good luck!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site:
http://www.word.mvps.org