Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
lucas4bi
Partner - Creator
Partner - Creator

How to set Background Image for a TextBox via Macro

Hello everyone,

i've been searching for a way to set a Background image to a textbox using macro functions.

I've already looked trought the forum and the API Guide but couldn't find this functionality.

Can somebody help me?

Thanks in advance

Luca

10 Replies
sushil353
Master II
Master II

Hi,

Please Find the attached the file.

Hope that will help you.

HTH

Sushil

lucas4bi
Partner - Creator
Partner - Creator
Author

Thank you sushil for the answer but that's not what i need.

I need to create a macro that creates new text box dinamically and applies to those textboxes a background image, it's not about switching or show/hide a predefined image.

flipside
Partner - Specialist II
Partner - Specialist II

It'll be a lot easier using bundled images ...

sub CreateTextBox

set mytext = ActiveDocument.ActiveSheet.CreateTextObject

prop = mytext.GetProperties

prop.Layout.Text.v = "='qmem://<bundled>/BuiltIn/thumb2.png'"

prop.Layout.ImageRepresentation.Presentation=1

prop.Layout.ImageRepresentation.Fallback=0

mytext.SetProperties prop

end sub

You may need to create two boxes, one for the background image and one for the text on top with transparent background in the same position. Lots of images will increase your document size.

flipside

lucas4bi
Partner - Creator
Partner - Creator
Author

Thank you, that could be a useful workaround.

So is there no way to create a new textbox inserting a background image directly?

lucas4bi
Partner - Creator
Partner - Creator
Author

The problem is i can't set the image transparency this way also 😕

flipside
Partner - Specialist II
Partner - Specialist II

It can be done. For the overlaying text box, you just need to set the background Color to a formula using ARGB.

'A' sets the transparency/opacity of the color, and the color you need is white - RGB(255,255,255). So, solid white background is ARGB(255,255,255,255) and 100% transparent is ARGB(0,255,255,255).

flipside

lucas4bi
Partner - Creator
Partner - Creator
Author

Yeah for the second text box with the text, but not for the first text box with the bundled image as text, there is no way to set the transparency for that.

That's why i'm wondering why there is no Qlikview function that allows you to set a Path for a background image in a textbox

flipside
Partner - Specialist II
Partner - Specialist II

Setting transparency on the top textbox will mimic setting transparency of the bottom box when using pure white as the base color - just that the transparency will be the reverse (100% transparent on the top box will equate to 100% opaque on the bottom box and vice versa). i.e. if you want to make the image 25% strength, then set the background of the top box to 75% strength (or 255 * 0.75 = 191 alpha value).

Regarding the macro code for setting the background image, the image is embedded in the document and not the path.  I'm sure there's probably a way around it, but I'd be surprised if it's easier than the route above.

flipside

lucas4bi
Partner - Creator
Partner - Creator
Author

Thanks, i didn't think about that, basically if the sheet's background is blue, you'll just need to use blue as background color for the top text and set the transparency