ActiveSheet.Shapes object location different on different computers

WhoCanDo

Board Regular
Joined
Dec 18, 2007
Messages
188
Using this code I am successfully positioning and rotating an object on my Excel sheet on multiple computers. However, on a laptop the objects are not in the correct location.

1616543804689.png
should be this

1616543864590.png
is this on the laptop

My thoughts are that it's the screen resolution differences. I set both to apps - 100% & resolution 1920 x 1080 with no solution.

Can someone suggest another direction?

Set cl = Range(Cells(ActiveCell.Row, 4).Address)
x1 = cl.Left
y1 = cl.Top

Set ActiveShape = ActiveSheet.Shapes.AddTextEffect(msoTextEffect31, "0", "Arial", 8, msoFalse, msoFalse, x1 - 9, y1 - 14)
ActiveShape.TextFrame.Parent.Rotation = -90
ActiveShape.Name = "A0" & ActiveCell.Row
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Here is a quick test I did.

With a column width of 11.29 and a row height of 15 ....

Sub test()
'
For i = 1 To 10 ' column
For j = 1 To 10 ' row
Cells(j, i).Select
Set cl = Range(Cells(ActiveCell.Row, ActiveCell.Column).Address)
ActiveCell.Value = cl.Left & " / " & cl.Top
Next j
Next i
End Sub


On most PC's the x / y cell co-ordinates are...

0 / 063 / 0126 / 0189 / 0252 / 0315 / 0378 / 0441 / 0504 / 0567 / 0
0 / 1563 / 15126 / 15189 / 15252 / 15315 / 15378 / 15441 / 15504 / 15567 / 15
0 / 3063 / 30126 / 30189 / 30252 / 30315 / 30378 / 30441 / 30504 / 30567 / 30
0 / 4563 / 45126 / 45189 / 45252 / 45315 / 45378 / 45441 / 45504 / 45567 / 45
0 / 6063 / 60126 / 60189 / 60252 / 60315 / 60378 / 60441 / 60504 / 60567 / 60
0 / 7563 / 75126 / 75189 / 75252 / 75315 / 75378 / 75441 / 75504 / 75567 / 75
0 / 9063 / 90126 / 90189 / 90252 / 90315 / 90378 / 90441 / 90504 / 90567 / 90
0 / 10563 / 105126 / 105189 / 105252 / 105315 / 105378 / 105441 / 105504 / 105567 / 105
0 / 12063 / 120126 / 120189 / 120252 / 120315 / 120378 / 120441 / 120504 / 120567 / 120
0 / 13563 / 135126 / 135189 / 135252 / 135315 / 135378 / 135441 / 135504 / 135567 / 135

and on the problem PC, they are...

0 / -1066 / -10132 / -10198 / -10264 / -10330 / -10396 / -10462 / -10528 / -10594 / -10
0 / 4.566 / 4.5132 / 4.5198 / 4.5264 / 4.5330 / 4.5396 / 4.5462 / 4.5528 / 4.5594 / 4.5
0 / 1966 / 19132 / 19198 / 19264 / 19330 / 19396 / 19462 / 19528 / 19594 / 19
0 / 33.566 / 33.5132 / 33.5198 / 33.5264 / 33.5330 / 33.5396 / 33.5462 / 33.5528 / 33.5594 / 33.5
0 / 4866 / 48132 / 48198 / 48264 / 48330 / 48396 / 48462 / 48528 / 48594 / 48
0 / 62.566 / 62.5132 / 62.5198 / 62.5264 / 62.5330 / 62.5396 / 62.5462 / 62.5528 / 62.5594 / 62.5
0 / 7766 / 77132 / 77198 / 77264 / 77330 / 77396 / 77462 / 77528 / 77594 / 77
0 / 91.566 / 91.5132 / 91.5198 / 91.5264 / 91.5330 / 91.5396 / 91.5462 / 91.5528 / 91.5594 / 91.5
0 / 10666 / 106132 / 106198 / 106264 / 106330 / 106396 / 106462 / 106528 / 106594 / 106
0 / 120.566 / 120.5132 / 120.5198 / 120.5264 / 120.5330 / 120.5396 / 120.5462 / 120.5528 / 120.5594 / 120.5
 
Upvote 0
Seems the row height and column width on the problematic pc is different from others.
 
Upvote 0
We are all using the same template and the sheet is locked from accidental changes like that.

Also, both PC's are 1920 x 1080 screen resolution.

Interestingly, cell A1 is at 0, -10. Minus 10 is off the sheet!

Has no one experienced this before?
 
Upvote 0
Just tested another laptop and the first cell is 0 / -12

The next two laptops all list A1 as 0 / 0

Also tested other PC's with different graphics cards to see if the graphics cards were affecting the results. They all listed A1 as 0 / 0 good.
 
Upvote 0
This worked for me

VBA Code:
Set cl = Range(Cells(ActiveCell.Row, 4).Address)
X1 = cl.Left
Y1 = cl.Top

Set ActiveShape = ActiveSheet.Shapes.AddTextEffect(msoTextEffect31, "0", "Arial", 8, msoFalse, msoFalse, X1, Y1)

With ActiveShape
    .Left = .Left - .Width / 2
    .Top = .Top - .Height * 6 / 7
    .TextFrame.Parent.Rotation = -90
    .Name = "A0" & ActiveCell.Row
End With
 
Upvote 0
Hi Jaafar,

Your code is a little neater that mine but still relies on cl.Left = 0 and cl.Top = 0 for cell A1

When the computer returns 0 / -10 then it is still misplaced.

However, you have given me a clue. All the cell numbers, x & y, are incrementing the same amount. Y is multiples of 15 on the PC and 14.5 on the laptop. On another laptop it's 14.4

I will calculate the different between cells and use the result as a modifier.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top