Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Change Background Macro


I try to make a macro to change background image of TextObject from another TextObject.

I use example from APIGuide 11

'Set the background image of an object from another

set mybox1 = ActiveDocument.GetSheetObject("LB01")

dim MyBlob

mbp1 = mybox1.GetProperties

MyBlob = mbp1.Layout.Frame.Background.ImageBlob

set mybox2 = ActiveDocument.GetSheetObject("LB02")

mbp2 = mybox2.GetProperties



mbp2.Layout.Frame.Background.ImageBlob = MyBlob

mybox2.SetProperties mbp2

I change Just "LB01" to "TX01" and "LB02" to "TX02" and code not work. But with ListBox code work perfectly.

Also i trying this code

'Set the background image of an object from another

set mybox1 = ActiveDocument.GetSheetObject("TX01")

dim MyBlob

mbp1 = mybox1.GetProperties

fbp1 = mybox1.GetFrameDef

MyBlob = fbp1.Background.ImageBlob

set mybox2 = ActiveDocument.GetSheetObject("TX02")

mbp2 = mybox2.GetProperties

fbp2 = mybox2.GetFrameDef



fbp2.Background.ImageBlob = MyBlob

mybox2.SetFrameDef fbp2

mybox2.SetProperties mbp2

No effect. Also, same situation with Button.

Anyone help?

Tags (3)
1 Reply
New Contributor III

Re: Change Background Macro


the ImageBlob property does not seem to work.

You can make this work by extracting the imagefile using the WriteXmlPropertiesFile property (Bmp node)

And setting it to the new object using the applytheme method

In c# :

XElement bmp = new XElement("Bmp");

bmp.Add(new XAttribute("enctype", "base64"));

bmp.Value = base64encodedFile;

XElement root = new XElement("QVTheme", new XElement("TextObjectProperties", new XElement("Layout", bmp)));

string objFileName = Path.GetTempFileName();




It's the only solution that I have found.

Oh and don't forget to set the UserSized property to true BEFORE applying the theme or else the object will resize to the image original size.

Best regards,


Community Browser