Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Hi,
Please Find the attached the file.
Hope that will help you.
HTH
Sushil
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.
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
Thank you, that could be a useful workaround.
So is there no way to create a new textbox inserting a background image directly?
The problem is i can't set the image transparency this way also 😕
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
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
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
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