1

I have a template file with several pages with text, and I want to make a Macro to add one image per page under the text.

I tried to adapt a script from Andrew Pitonyak, but the result is not as expected, I probably missed something to force a page break.

    Sub Main
      InsertImage("file1.jpg", 25000, 12158, 3000, 5500)
      InsertImage("file2.jpg", 25000, 12158, 3000, 30500)
    End Sub

    Sub InsertImage(sURL$, sizeW, sizeH, posX, posY)    
      REM Author: Andrew Pitonyak
      Dim oSize As New com.sun.star.awt.Size
      Dim oPos As New com.sun.star.awt.Point
      Dim oGraph
      
      oDoc = ThisComponent
        
      REM First, create a graphic object shape
      oGraph = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
    
      REM Size and place the graphic object.  
      oSize.width=sizeW
      oSize.height=sizeH
      oGraph.setSize(oSize)
    
      oPos.X = posX
      oPos.Y = posY
      oGraph.setposition(oPos)
    
      REM Assuming a text document, add it to the single draw page.
      oDoc.getDrawpage().add(oGraph)
    
      REM Set URL to the image.
      oGraph.GraphicURL = sURL
    End Sub   

Here what I expected

And what is done

Did anyone can help me to understand how it works ?

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
DebPokus
  • 13
  • 3

0 Answers0