d'accords je coorige et te donne la ligne pour qu'elle soit universelle ta fonction
Version imprimable
d'accords je coorige et te donne la ligne pour qu'elle soit universelle ta fonction
voila
donc soitCode:cadre = IIf(Application.OperatingSystem Like "*10*" And Application.Version <> 12, -5, 1)
window10 et excelXXXX mais pas 2007 =-5
window7 et excel 2007 =1
window10 et excel 2007 =1 même si le shell de w10 n'affiche pas le cadres des fenêtres comme w7
voila
erreur13 imcompatibilité de type, quand je met le curseur sur cadre il est cadre = vide
cadre = IIf(Application.OperatingSystem Like "*10*", -5, 1)
comme ça ça marche
allons donc???
msgbox Application.OperatingSystem Like "*10*"
msgbox application.verion <>12
cadre = IIf(Application.OperatingSystem Like "*10*" And Application.Version = "16.0", -5, 1)
comme ça c'est ok
je t'es mis message au dessus 16.0
alors ca devrait marcher
a moins qu'avec val
ou bien encoreCode:cadre = IIf(Application.OperatingSystem Like "*10*" And val( Application.Version )<> 12, -5, 1)
Code:cadre = IIf(Application.OperatingSystem Like "*10*" And not Application.Version like"*12*", -5, 1)
T'es un champion, ça marche nickel avec l'une ou l'autre, merci
re
Bonjour Nicolas
maintenant on peut le dire c'est universel
maintenant que tu comprends ma logique tu peut essayer de reprendre la méthode de Jacques en essayant de lui affublé cette condition
elle sera universel aussi
la seule chose qui me gène dans ta version c'est le( -5 /+1)qui fonctionne mais on ne sais pas ou il les prends
je préfèrerait que tu trouve une dimension dans excel
perso j'ai pensé a ceci:
X=round((cells(rows.count,columns.count).height/3))'=5
il faudrait que tu teste voir si c'est pareil chez toi avec ou sans zoom
que donne le rsultat de ca chez toi vu qu'avec W10 le cadre est absent
Code:usable = Application.Width - Application.UsableWidth
et application.width-application.usablewidth ca donne quoi! chez toi
12
c'est ce qui explique le + ou - 6
mais pour l'universalité c'et inexploitable car chez moi c'est 9.086xxxxx
ca m'ennuie d'utiliser une cells pour le 5 car elle pourrait être éventuellement modifiée
faut chercher encore
on finira bien par trouver
j'ai un doute
essaie -4 plutôt chez toi et teste a 100 et 200%
escuse moi je m'étais planter, à force je mi perds, le résultat à l'œil est le même, j'ai essayé à 400%, je vois rien de différent
Quand je mets la colonne A à 20pix et avec 4 j'ai un décalage, mais en 5 je suis toujours ok
1er à 4 et l'autre à 5 et colonne A réduite à 20
Pièce jointe 280809
Pièce jointe 280811
d'accord donc -4 c'est bon j'ai toi et +4 c'est c'est bon chez moi a vu d'œil bien évidement
donc si chez toi
donne 12Code:cadre=Application.Width - Application.UsableWidth
et chez moi ca donne '9.59999999999991
et que chez toi entre -5 et -4 tu vois pas la différence
on peut faire alors
on a ainsi une mesure génériqueCode:
1
2 cadre = Application.Width - Application.UsableWidth cadre = IIf(Application.OperatingSystem Like "*10*" And Val(Application.Version) <> 12, -cadre / 3, cadre / 2)
edit c'est bon j'ai un calcule qui me donne -5 pour toi et 4 pour moi
c'est cadre/2.4
Avec ce code parce que j'ai d'autre test mais c'est le bordel
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 Function PositionForm(usf, rng) Dim Z As Double, K As Double, E As Double Z = ActiveWindow.Zoom / 100 K = ((ActiveWindow.ActivePane.PointsToScreenPixelsX(ActiveSheet.[A1].Width) - ActiveWindow.ActivePane.PointsToScreenPixelsX(0)) / ActiveSheet.[A1].Width) / Z E = IIf(Application.OperatingSystem Like "*10*" And Val(Application.Version) <> 12, -5, 1) lleft = (ActiveWindow.PointsToScreenPixelsX(rng.Left * K * Z) / K) + E ttop = ActiveWindow.PointsToScreenPixelsY(rng.Top * K * Z) / K Wwidth = IIf(rng.Columns.Count > 1, (rng.Width * Z) + 10, usf.Width) Hheight = IIf(rng.Rows.Count > 1, (rng.Height * Z) + 5, usf.Height) PositionForm = Array(lleft, ttop, Wwidth, Hheight) UserForm1.Label1.Caption = "Zoom" & " " & Z * 100 End Function
escuse mais revoie les com précédent
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 Function PositionForm2(usf, rng) Dim Zooom#, PtToPx#, cadre#, usable# cadre = Application.Width - Application.UsableWidth cadre = IIf(Application.OperatingSystem Like "*10*" And Val(Application.Version) <> 12, -cadre / 2.4, cadre / 2.4) With ActiveWindow Zooom = .Zoom / 100 PtToPx = ((.ActivePane.PointsToScreenPixelsX(ActiveSheet.[A1].Width) - .ActivePane.PointsToScreenPixelsX(0)) / ActiveSheet.[A1].Width) / Zooom lleft = (.PointsToScreenPixelsX(rng.Left * PtToPx * Zooom) / PtToPx) + cadre ttop = .PointsToScreenPixelsY(rng.Top * PtToPx * Zooom) / PtToPx Wwidth = IIf(rng.Columns.Count > 1, rng.Width * (Zooom) - usable + cadre, usf.Width) Hheight = IIf(rng.Rows.Count > 1, rng.Height * Zooom - usable, usf.Height) End With PositionForm2 = Array(lleft, ttop, Wwidth, Hheight) End Function Sub TestUserformtopleftcell2() r = PositionForm2(UserForm1, [b3]) With UserForm1: .Show 0: .Left = r(0): .Top = r(1): End With End Sub
oui ça colle
c'est quoi le usable ?Citation:
Wwidth = IIf(rng.Columns.Count > 1, rng.Width * (Zooom) - usable + cadre, usf.Width)
désolé
donc maintenant occipons noude tes deux lignes suivantes
chez toi
il est facile de remplacer ton +10 par +cadre*2Code:
1
2 Wwidth = IIf(rng.Columns.Count > 1, (rng.Width * Z) + 10, usf.Width) Hheight = IIf(rng.Rows.Count > 1, (rng.Height * Z) + 5, usf.Height)
et donc ton +5 par +cadre
et donc chez moi
Wwidth = IIf(rng.Columns.Count > 1, rng.Width * Zooom - cadre * 2, usf.Width)
Hheight = IIf(rng.Rows.Count > 1, rng.Height * Zooom - cadre, usf.Height)
il nous reste plus qu'a combiner ces 4 lignes en une pour le générique
usable tu peut l'enlever il sert plus a rien
je suis obligé de mettre en "-" pour que sa passeCode:
1
2 Wwidth = IIf(rng.Columns.Count > 1, (rng.Width * Zooom) - cadre * 2, usf.Width) Hheight = IIf(rng.Rows.Count > 1, (rng.Height * Zooom) - cadre, usf.Height)
bon ben chose étonnante c'est pareil pour nous deux
Ben un coup c'est + et un coup c'est -, mais ça marche
c'est normal les - a la place des + les "- -"="+"
change moi les + en moins la ou il faut chez toi sauf dans la ligne "cadre=iif........"
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 Function PositionForm2(usf, rng) Dim Zooom#, PtToPx#, cadre#, usable# cadre = Application.Width - Application.UsableWidth cadre = IIf(Application.OperatingSystem Like "*10*" And Val(Application.Version) <> 12, -cadre / 2.4, cadre / 2.4) With ActiveWindow Zooom = .Zoom / 100 PtToPx = ((.ActivePane.PointsToScreenPixelsX(ActiveSheet.[A1].Width) - .ActivePane.PointsToScreenPixelsX(0)) / ActiveSheet.[A1].Width) / Zooom lleft = (.PointsToScreenPixelsX(rng.Left * PtToPx * Zooom) / PtToPx) + cadre ttop = .PointsToScreenPixelsY(rng.Top * PtToPx * Zooom) / PtToPx + cadre Wwidth = IIf(rng.Columns.Count > 1, rng.Width * (Zooom) - cadre * 2, usf.Width) Hheight = IIf(rng.Rows.Count > 1, rng.Height * Zooom - cadre, usf.Height) End With PositionForm2 = Array(lleft, ttop, Wwidth, Hheight) End Function
Problème sur le top
Pièce jointe 280839Code:ttop = .PointsToScreenPixelsY(rng.Top * PtToPx * Zooom) / PtToPx + cadre
Pièce jointe 280843Code:ttop = .PointsToScreenPixelsY(rng.Top * PtToPx * Zooom) / PtToPx - cadre
a oui c'est vrai tu n'en a pas besoins pour le top
non
voila ne change rien teste c'est tout
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 Function PositionForm2(usf, rng) Dim Zooom#, PtToPx#, cadre#, system system = Application.OperatingSystem cadre = Application.Width - Application.UsableWidth cadre = IIf(system Like "*10*" And Val(Application.Version) <> 12, -cadre / 2.4, cadre / 2.4) With ActiveWindow Zooom = .Zoom / 100 PtToPx = ((.ActivePane.PointsToScreenPixelsX(ActiveSheet.[A1].Width) - .ActivePane.PointsToScreenPixelsX(0)) / ActiveSheet.[A1].Width) / Zooom lleft = (.PointsToScreenPixelsX(rng.Left * PtToPx * Zooom) / PtToPx) + cadre ttop = .PointsToScreenPixelsY(rng.Top * PtToPx * Zooom) / PtToPx + IIf(system Like "*6*", cadre, 0) Wwidth = IIf(rng.Columns.Count > 1, rng.Width * (Zooom) - cadre * 2, usf.Width) Hheight = IIf(rng.Rows.Count > 1, rng.Height * Zooom - cadre, usf.Height) End With PositionForm2 = Array(lleft, ttop, Wwidth, Hheight) End Function
ouais ça colle et avec le zoom pas de problème non plus
voila on a maintenant une fonction compatible avec
W7 2007
W10 2007
W10 2010
W10 2013
W10 2016
demain je récupèrerais mon ancien PC portable si je trouve le chargeur est j'essaierais sur XP2003
on est les champions
et plus de données numérique en dur on prends tout dans excel sauf le 2.4 mais comme il est identique pour tous on le prendra pas en compte
Plus toi que moi, mais si tu as des expériences appel moi c'est très instructifCitation:
on est les champions