Hi Jo,
you have to set the Property AnchorPageNo for the inserted graphic after
setting anchor type, for example
oGraph.AnchorPageNo = 2
Hope that helped...
Mathias
Jo schrieb:
Hi,
What I'm trying to achieve is to insert a picture into writer and have
it anchored to the page. I don't understand why I can't set the
position in a straightforward way. I found oGraph has a method
getPosition(), but it doesn't want to work. I had hoped to use
setPostion(oPos), but I'm not having much luck there either.
Then I tried with HoriOrientPosition, since I found somebody's code
where he was doing that with a frame. Do I have to embed my picture in
a frame if I want to position it anchored to the page?
Sub Main
InsertGraphicObject(ThisComponent,
"file:///E:/headlinetype01.gif") End Sub
Sub InsertGraphicObject(oDoc, sURL$)
REM Author: Andrew Pitonyak
Dim oCursor
Dim oGraph
Dim oText
Dim oPos As New com.sun.star.awt.Point
oText = oDoc.getText()
oCursor = oText.createTextCursor()
oCursor.goToStart(FALSE)
oGraph = oDoc.createInstance("com.sun.star.text.GraphicObject")
With oGraph
.GraphicURL = sURL
.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
.HoriOrientPosition=1000 ' This doesn't seem to have any effect.
.VertOrientPosition=1000 ' The graphic is simply inserted
centered horizontally across the page
' glued against the top.
End With
' Xray OGraph
'now insert the image into the text document
oText.insertTextContent( oCursor, oGraph, False )
' print oGraph.getPosition() ' Found this method with Xray
' BASIC runtime error
' An exception occurred
' Type: com.sun.star.uno.RuntimeException
' Message: position cannot be determined with this method.
With oPos
.X = 1000
.Y = 1000
End With
oGraph.setPosition(oPos) ' Found this method with Xray
' Message: position cannot be changed with this method.
End Sub
Yours ever more in despair,
Jo
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]