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

Copy coordinates to other objects

Hi,

Let's say I have 3 objects on a sheet and call them (o1, o2 and o3).  Make the assumption o2 sits at

these coordinates (10,20,30,40).  Is there a quick way I can apply these same coordinates to o3 instead of

manually entering them?

Thanks!

9 Replies
robert_mika
Master III
Master III

The simple answer is not.

You can not create variables or change all at the same time.

The ways of doing would be:

VBA - create 3 objects at the same location.

Take a screenshot of the first object and then apply the same  coordinates to others(yours are the simple one but in case you had a more complicated parameters.

I'm using this method quite often.

el_aprendiz111
Specialist
Specialist

Hi,

it can be useful:

SUB  Various

set sh = ActiveDocument.ActiveSheet

for i = 0 to sh.NoOfSheetObjects-1

    set obj = sh.SheetObjects(i)

    pos = obj.GetRect

    pos.Top = 100'pos.Top + 20

    pos.Left = pos.Left + 15

   

    obj.SetRect pos

next

end sub

Anonymous
Not applicable
Author

Robert,

Would you mind posting a sample qvw file so I can checkout your technique?  I'm new to QV but I can

understand code if I see it.  Thanks.

Anonymous
Not applicable
Author

fer fer,

It looks your sub() is iterating through all the objects on the sheet and setting them to the coordinates defined by

"pos".  Is this correct?  What about just a specific object?  Is there a property of the "obj" to evaluate the object name?

el_aprendiz111
Specialist
Specialist

Hi,

Makro_Height.gif

Anonymous
Not applicable
Author

fer fer,

Thanks so much for spending your time to create this video.  I am going to try to follow it and see if I get it

working the way I need it.  Will follow up again next  time.

robert_mika
Master III
Master III

The code below will create 3 text object in the same position

Sub Textboxes

  for i = 1 to 3

  set mytext = ActiveDocument.ActiveSheet.CreateTextObject

  strObjID = mytext.GetObjectID

  set fr = mytext.GetFrameDef

     pos = fr.Rect

     pos.Top = 60

     pos.Left = 60

  pos.Width = 160

  pos.Height = 190

     mytext.SetFrameDef fr

next

end sub

Anonymous
Not applicable
Author

Thanks Robert. 

Will follow up in the next few days as I'm still exploring all the suggestion posted here.

settu_periasamy
Master III
Master III

May be try this also,

Make one object as a proper position. then select all other objects . Make it as 'Align Left' , then 'Align top' using design option