Problem trying to insert a object picture in a certain page

A

AutomationGuy

Hi I´m doing some automation of word document, and I need to erease a object
picture and add a new one with the same attributes of that one already
erased, but when the object is not placed at the first page when I insert the
new object it always go to the first page I have this code:

dLineWeight = objShape.Line.Weight
lLineStyle = objShape.Line.Style
lLineVisible = objShape.Line.Visible
dLineTransparency = objShape.Line.Transparency

' Save the color details of the original socket.
lFillColor = objShape.Fill.ForeColor.RGB
lLineForeColor = objShape.Line.ForeColor.RGB

' Save all the properties of the place holder.
nLeft = objShape.Left
nTop = objShape.Top
nSocketHeight = objShape.Height
nSocketWidth = objShape.Width

objShape.LockAnchor = True
lHoriRelativePos = objShape.RelativeHorizontalPosition
lVertRelativePos = objShape.RelativeVerticalPosition
lPhotoWrapType = objShape.WrapFormat.Type
lPhotoAllowOverlap = objShape.WrapFormat.AllowOverlap
objShape.Anchor.Select

' Collapse the selection
Selection.Collapse (wdCollapseEnd)


Set NewShape =
m_objDocument.Shapes.AddOLEObject(Anchor:=Selection.Range,
ClassType:="DIYPhoto_Object", FileName _
:="", LinkToFile:=False, DisplayAsIcon:=False)

As you can see I used collapse to get at the correct page but when I added
the new object is alwast go to the first page. I don´t know what to do.

thank you in advance.

Another thing that I would like to know is how can I get the actual posicion
of pointer. I mean to know in which page I am and the line and colum in the
page.

Thanks again.
 
C

Chuck

I’m just guessing but it seems that your selection point is on the first page
(ie the page where the first shape is) not where you think it should be -
your posted code doesn’t show how you position your selection before
collapsing it.

Rather than using Selection you might try using a Range object to position
your new shape object.

If you want information about your selection/range, use the Information
property (eg Selection.Range.Information).

HTH
 

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