04-25-2017 07:28 AM
Hello
I wanted to be able to programmatically center report objects, such as a text box and a 2D curve plots, with each other.
Thanks
DIAdem 2015 SP2 32 bit
Solved! Go to Solution.
04-26-2017 08:20 AM - edited 04-26-2017 08:27 AM
Center objects in Sheet center:
Dim oCtrl, PageWidth, ObjWidth PageWidth = Report.ActiveSheet.Dimensions.Width for each oCtrl in Report.ActiveSheet.Objects ObjWidth = oCtrl.Position.ByCoordinate.Width oCtrl.Position.ByCoordinate.X1 = PageWidth / 2 - ObjWidth / 2 oCtrl.Position.ByCoordinate.X2 = PageWidth / 2 + ObjWidth / 2 next call Report.Refresh()
Center objects at center of another object:
Dim oCtrl, CenterPos, ObjWidth, RefObject
set RefObject = Report.ActiveSheet.Objects("TextObject1")
CenterPos = RefObject.Position.ByCoordinate.X1 + RefObject.Position.ByCoordinate.Width / 2
for each oCtrl in Report.ActiveSheet.Objects
if not oCtrl is RefObject then
ObjWidth = oCtrl.Position.ByCoordinate.Width
oCtrl.Position.ByCoordinate.X1 = CenterPos - ObjWidth / 2
oCtrl.Position.ByCoordinate.X2 = CenterPos + ObjWidth / 2
end if
next
call Report.Refresh()