Object positioning

Copper Contributor

I have an excel worksheet that creates a diagram.    Below are attached the original creation of the diagram and also the new version of the diagram from the modified program.  The user wants to know why things are not lining up in the new version like they did in the old version.  I find nowhere in any of the code related to the worksheet where positioning is determined to place the items in the diagram.  Can anyone point me as to how to correct the problem?

 

Thanks.

8 Replies
Can anyone help me with the issue above?

@jragan 

I can see why your client is not totally thrilled.  If you go into the VBA, shape positions may be set by using their .left and .top properties.  Ranges also return such properties so the shape could either be set by the location in points or set to match the grid.

Set shp = Sheet1.Shapes(1)
shp.left = rng.left
shp.Top = rng.Top
shp.Rotation = 45
Peter,
Thank you for your reply. The problem for me is that I do not see any code that is assigning position to any shape as you have demonstrated above. I will keep looking though.

Thank you again.

John
John
How was the diagram created? Was it simply a diagram created by hand? Changing the size of the underlying mesh can change the shapes, depending on their settings. Rotating shapes is unusual, though.
The diagram is actually created by VBA code. The objects are all defined and the shapes are turned on or off depending on user input on the excel sheet. It does not use any positioning logic and from what I am learning from the user they reposition objects to line up they way they want them for each diagram created for their customer. Thank you for your answer.

@jragan 

Many things are possible using VBA.  What is desirable or worth the effort is another matter.  For example, once the shapes have been positioned manually a 'record button' could store the position and visibility of shapes to a data table on a hidden sheet.  That would allow a 'reset' button that takes the diagram back to a default state.  The properties of Excel shapes are sufficient to allow the shape to be extruded and positioned in 3D with changing lighting options.

 

For some slightly over the top graphics see

2048 game version for Excel (spreadsheet1.com)

Thanks. One last question. When you manually reposition a shape does it always reappear in the last spot it was placed in when used again?

Thank You again.

John

@jragan 

Opening and closing files should not cause shapes to move or change proportions.  Changes that are made to the grid can have drastic repercussions depending on the shape properties.

image.png

The default is for shapes to move and size with the grid.