Replacing a pictures properties with another pictures properties 
Author Message
 Replacing a pictures properties with another pictures properties

Hi,

I have a Word document with some text and a picture. The picture is places
below the text.

I want to replace the picture with another picture. The new picture could be
smaller or larger, so I scale the new picture to fit the old size.

I have managed to set the picture size, but I have problems getting the same
placement even though I copy the height, width, top and left. I think it is
the anchoring that I havent been able to copy, but I am unsure what in the
anchor to copy.

Do you have any suggestions how to get the same anchoring as the old picture
or maybe the anchoring is'nt the problem?

Here is my code:

                   ' Insert the new picture
                    Set shpNewPicture=
objWord.ActiveDocument.Shapes.AddPicture( _

FileName:="D:\Prosjekter\Exact\InterdevProsjekt\Exact\Exact_Local\Dokument\t
est.bmp", _
                            LinkToFile:=False, _
                            SaveWithDocument:=True)

                    ' Transfer the properties to the new picture
                    With shpOriginalPicture
                        shpNewPicture.LockAspectRatio = msoFalse
                        shpNewPicture.Height = .Height
                        shpNewPicture.Width = .Width
                        shpNewPicture.Left = .Left
                        shpNewPicture.Top = .Top
                        shpNewPicture.WrapFormat.Type = .WrapFormat.Type
                        shpNewPicture.WrapFormat.Side = .WrapFormat.Side
                        shpNewPicture.Fill.Visible = .Fill.Visible
                        shpNewPicture.Line.Visible = .Line.Visible
                        shpNewPicture.Anchor.Start = .Anchor.Start
                        shpNewPicture.Anchor.End = .Anchor.End
                        shpNewPicture.TextFrame.MarginBottom =
.TextFrame.MarginBottom
                        shpNewPicture.TextFrame.MarginLeft =
.TextFrame.MarginLeft
                        shpNewPicture.TextFrame.MarginRight =
.TextFrame.MarginRight
                        shpNewPicture.TextFrame.MarginTop =
.TextFrame.MarginTop
                        shpNewPicture.Anchor.Characters = .Anchor.Characters
                        shpNewPicture.Anchor.Characters = .Anchor.Characters
                    End With



Tue, 19 Nov 2002 03:00:00 GMT  
 Replacing a pictures properties with another pictures properties
Hi Are,

Quote:
> Do you have any suggestions how to get the same anchoring as the old picture

The .AddPicture method for a Shape has an Anchor argument, which is a range.
Try something along these lines:

    Dim rngAnchor as Word.Range

    Set rngAnchor = YourShape.Anchor
    'Code to remove the old shape
    'Insert the new shape
    ActiveDocument.Shapes.AddPicture _
        FileName:="TheFile", _
        Anchor:=rngAnchor

Besides the Top and Left settings, plus the anchor range, you also need to
ensure that the RelativeHorizontal and RelativeVertical positions match.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Wed, 20 Nov 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. From hDC property to Picture property

2. Setting the picture property of an image

3. Property for a picture

4. Properties for pictures in a document

5. Save Preview Picture property

6. Form Scaling/Picture property

7. Object Referance to Picture Property

8. Saving and retrieving image control picture property in MSSQL7

9. Help! To change picture property of rptimage @ runtime

10. About Picture Property

11. Picture Property Of Image

12. Question regarding setting a Picture property in a Usercontrol

 

 
Powered by phpBB® Forum Software