Hello. I try to replace every occurrence of a certain string by an image. It loops, but writer only replaces the first occurence and I don't see why. Here ist the code: I am using LO 4.1 The code: Sub InsertLogo() Dim oGraph Dim oDescriptor 'The search descriptor Dim oFound 'The found range Dim oFoundAll 'The found range Dim n% 'General index variable Dim oCursor oGraph = ThisComponent.createInstance("com.sun.star.text.GraphicObject") With oGraph .GraphicURL = "file://localhost/anydirectory/logo.png" .AnchorType = com.sun.star.text.TextContentAnchorType.AS_CHARACTER .Width = 910 .Height = 420 .VertOrient = 4 'CHAR_TOP End With oDescriptor = ThisComponent.createSearchDescriptor() oDescriptor.SearchString = "{logo}" oFoundAll = ThisComponent.findAll(oDescriptor) For n% = 0 to oFoundAll.getCount()-1 oFound = oFoundAll.getByIndex(n%) oFound.setString("") oCursor = oFound.getStart() oFound.getText().insertTextContent( oCursor, oGraph, False ) Next End Sub
Hi Bern, Working with graphics is a bit not straight forward (for me). I would try to make new instances (oGraph_n) for each replace. No idea if that works. But it's not a support forum here, is it ;) Could you find another place for help? regards, Cor
Dear Cor. Thanks for having a look at it. I looked for help in several forums but I found/got no answer. I'll try as you advised. Just being curious: Why isn't that a straight forward approach. I thought it is. :) Thanks Bernd
This bug tracker is not an helpdesk. Please ask for help on users mailing-list (users@global.libreoffice.org) or on http://ask.libreoffice.org Closing as invalid. Bes regards. JBF