Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Text Object Creation via Macro

Hi All,

i am trying to create a Text object Object using macro below is the code.

set obj = ActiveDocument.ActiveSheet.CreateTextObject

  prop = obj.GetProperties

  'Image Presentation

  prop.Layout.Text.v = "= 'qmem://ImageId/arrowU_off'

  prop.Layout.ImageRepresentation.Presentation=1

  prop.Layout.ImageStyle.StrechMode=0

i am able to create a text object which represent Image successfully, but issue is that Image StrectMode is ON which i want to OFF by using macro only i have tried the code prop.Layout.ImageStyle.StrechMode=0 but this is not working.

Please help how to do this.

Thanks & Regards,

Jitendra Kumar.

1 Solution

Accepted Solutions
tamilarasu
Champion
Champion

Hi Jitendra,

I have found it after a long search. But I felt frustrating to search the correct syntax to access the properties through macro. Lack of examples in API guide.

Sub Test

    set obj = ActiveDocument.ActiveSheet.CreateTextObject

    prop = obj.GetProperties

    'Image Presentation

    prop.Layout.Text.v = "= 'qmem://ImageId/arrowU_off' "

    prop.Layout.ImageRepresentation.Presentation=1

    prop.Layout.ImageRepresentation.CellImageStyle.StretchMode = 0

    obj.SetProperties prop

End Sub


Let me know.

View solution in original post

9 Replies
petter
Partner - Champion III
Partner - Champion III

In you code I can't find a

     obj.SetProperties prop

Which is necessary to activate the changes you have made on the object you are manipulating...

tamilarasu
Champion
Champion

Hi Jitendra,

Try the below syntax,

prop.Layout.BkgImageSettings.ImageStyle.StretchMode = 0

Not applicable
Author

In code i am doing obj.SetProperties prop

Not applicable
Author

Hi Tamil Nagaraj,

i have tried that. its did not giving me any error but still it not working.

Not applicable
Author

Hi Tamil Nagaraj,

using you code is changing red marked properties, i want to change blue marked property of text object.

ImageStretch.PNG

tamilarasu
Champion
Champion

Hi Jitendra,

I have found it after a long search. But I felt frustrating to search the correct syntax to access the properties through macro. Lack of examples in API guide.

Sub Test

    set obj = ActiveDocument.ActiveSheet.CreateTextObject

    prop = obj.GetProperties

    'Image Presentation

    prop.Layout.Text.v = "= 'qmem://ImageId/arrowU_off' "

    prop.Layout.ImageRepresentation.Presentation=1

    prop.Layout.ImageRepresentation.CellImageStyle.StretchMode = 0

    obj.SetProperties prop

End Sub


Let me know.

Not applicable
Author

Thanks Tamil nagaraj,

Its working fine.

Agree with your point i am also very frustrated to search the correct syntax.

5abi0001
Creator
Creator

Is it also possible to set actions via macro? like when creating the textbox to set actions like run a macro?

tamilarasu
Champion
Champion

Yes. It is possible. I would suggest you to create a new discussion since this one is already closed and more than 2 year old. Hope this is fine with you. Don't forget to mention my name after creating a new discussion, so that I'll get a notification. Have a nice day.