Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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.
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
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.
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?
Hi,
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.
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
Thanks Robert.
Will follow up in the next few days as I'm still exploring all the suggestion posted here.
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