Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Loading images using a macro

Hi Everyone,

I'm fairly new to qlikview and with one project under my belt I'm looking at a new one which is a lot more challenging.

Basically the document will need to retrieve images from a file store on the network based on the criteria set in the list boxes. I can't load the images into the document as there could potentially be thousands of images. I've started playing around to prove this can be done and decided that a macro is the only approach. So far I can click on a value in a listbox and then push a button, this triggers a macro which goes and retrieives the image and displays it in a container for me which is great. I can also do this for multiple images as well now, but I have 2 problems...

1. I don't know the syntax to set the Image Strech to Keep Aspect (cant seem to find it anywhere for Foreground image

2. The 2nd, 3rd pics that I load are very blurry and lose quality, if I load the images without a container the quality is perfect

Below is the Macro I have so far:

sub OpenPics_Cont

IMG_PATH = "C:\Users\Public\Pictures\Sample Pictures\"

Set ContainerObj = ActiveDocument.Sheets("Main").CreateContainer

set ContProp=ContainerObj.GetProperties

set LB = ActiveDocument.GetSHeetObject("LB01")

pg=LB.GetPossibleValues

    for i=lbound(pg) to ubound(pg)

        set mytext=ActiveDocument.ActiveSheet.CreateTextObject

        prop=mytext.GetProperties

        prop.Layout.ImageRepresentation.Presentation = 1

        prop.Layout.Text.v = "='" & IMG_PATH & pg(i) & ".jpg'"

        mytext.SetProperties prop

        ContProp.ContainedObjects.Add

        ContProp.SingleObjectMode=1

        ContProp.SingleObjectStyle=1

        ContProp.ShowObjectTypeIcons=true

        ContProp.ContainedObjects.Item(i).Id =prop.Layout.Frame.ObjectId

        ContProp.ContainedObjects.Item(i).Text.v = pg(i)

        ContainerObj.SetProperties ContProp

        mytext.close

    next

end sub

Does anyone have any idea's how I might be able to adjust the aspect of the image and why the image quality is so bad.

10 Replies
Not applicable
Author

I can create a largish table box set the size and disable move/size then it will show 1 image and the scrollbar will be available for instances of multiple images.

That will work great.

Thank you for all your help Isaiah.