Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

liste des macros + raccourcis claviers

5 réponses
Avatar
Vincent_C
bonjour à tous,

pour avoir la liste des macros + les raccourcis clavier, j'utilisais la
macro suivante sous excel 2003 :

Sub ListeMacros()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer

Application.ScreenUpdating = False
Workbooks.Add.Worksheets(1).[A1:B1] = [{"Procédure","Raccourci"}]

SendKeys "%{F8}%a{PGUP}{TAB}{ESC}"

'nécessite une référence à la bibliothèque
'Microsoft Forms 2.0 Object Library
With New DataObject
Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
SendKeys Rpt & "%n^c{ESC}", True
.GetFromClipboard
If Macro = .GetText(1) Then Exit Do
Macro = .GetText(1)
SendKeys Rpt & "%t^c{ESC}{ESC}", True
.GetFromClipboard
Racc = .GetText(1)
I = I + 1
Cells(I + 1, 1) = Macro
If Racc <> Macro Then Cells(I + 1, 2) = "Ctrl-" & Racc
Loop
End With
With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub

dans excel 2007 elle ne fonctionne pas alors que la bibliothèque Microsoft
Forms 2.0 Object Library est bien activée

pouvez vous m'aider s'il vous plait ?

d'avance merci !

bien cordialement,
Vincent_C

5 réponses

Avatar
michdenis
Bonjour Vincent,

J'ai testé cette macro écrite par Laurent Longre, je crois,
et elle fonctionne dans très bien dans la version Excel 2007.

Je me suis contenté seulement d'en faire un copier-coller dans
un module standard et d'ajouter la référence.




"Vincent_C" a écrit dans le message de groupe de
discussion :
bonjour à tous,

pour avoir la liste des macros + les raccourcis clavier, j'utilisais la
macro suivante sous excel 2003 :

Sub ListeMacros()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer

Application.ScreenUpdating = False
Workbooks.Add.Worksheets(1).[A1:B1] = [{"Procédure","Raccourci"}]

SendKeys "%{F8}%a{PGUP}{TAB}{ESC}"

'nécessite une référence à la bibliothèque
'Microsoft Forms 2.0 Object Library
With New DataObject
Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
SendKeys Rpt & "%n^c{ESC}", True
.GetFromClipboard
If Macro = .GetText(1) Then Exit Do
Macro = .GetText(1)
SendKeys Rpt & "%t^c{ESC}{ESC}", True
.GetFromClipboard
Racc = .GetText(1)
I = I + 1
Cells(I + 1, 1) = Macro
If Racc <> Macro Then Cells(I + 1, 2) = "Ctrl-" & Racc
Loop
End With
With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub

dans excel 2007 elle ne fonctionne pas alors que la bibliothèque Microsoft
Forms 2.0 Object Library est bien activée

pouvez vous m'aider s'il vous plait ?

d'avance merci !

bien cordialement,
Vincent_C
Avatar
isabelle
bonjour à vous deux,

je l'ai testé sur xl2002, je confirme que la macro fonctionne très bien,

isabelle

michdenis a écrit :
Bonjour Vincent,

J'ai testé cette macro écrite par Laurent Longre, je crois,
et elle fonctionne dans très bien dans la version Excel 2007.

Je me suis contenté seulement d'en faire un copier-coller dans
un module standard et d'ajouter la référence.




"Vincent_C" a écrit dans le message de groupe de
discussion :
bonjour à tous,

pour avoir la liste des macros + les raccourcis clavier, j'utilisais la
macro suivante sous excel 2003 :

Sub ListeMacros()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer

Application.ScreenUpdating = False
Workbooks.Add.Worksheets(1).[A1:B1] = [{"Procédure","Raccourci"}]

SendKeys "%{F8}%a{PGUP}{TAB}{ESC}"

'nécessite une référence à la bibliothèque
'Microsoft Forms 2.0 Object Library
With New DataObject
Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
SendKeys Rpt & "%n^c{ESC}", True
.GetFromClipboard
If Macro = .GetText(1) Then Exit Do
Macro = .GetText(1)
SendKeys Rpt & "%t^c{ESC}{ESC}", True
.GetFromClipboard
Racc = .GetText(1)
I = I + 1
Cells(I + 1, 1) = Macro
If Racc <> Macro Then Cells(I + 1, 2) = "Ctrl-" & Racc
Loop
End With
With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub

dans excel 2007 elle ne fonctionne pas alors que la bibliothèque Microsoft
Forms 2.0 Object Library est bien activée

pouvez vous m'aider s'il vous plait ?

d'avance merci !

bien cordialement,
Vincent_C




Avatar
FS
Bonjour,

Contrairement à mes petits camarades, je n'arrive à faire tourner ce
code (qui est de LL me semble-t-il) avec Excel 2007 ( .GetText(1) ne
passe pas) et il ne fonctionne pas très bien non plus avec Excel 2003
(la récupération des raccourcis clavier ne se fait pas).
Je te propose une autre approche (sans DataObject). Elle semble
fonctionner correctement avec Excel 2007, mais pas avec Excel 2003 (mais
ce n'était pas ta question).
A tester (et à exécuter depuis Excel et non dans l'éditeur VBE) :

'====================== Sub ListeMacros_2()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer
Dim Wbk As Workbook

' Application.ScreenUpdating = False
Set Wbk = Workbooks.Add
Wbk.Worksheets(1).[A1:B1] = [{"Procédure","Raccourci"}]
SendKeys "%{F8}%a{PGUP}{TAB}{ESC}", True

Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
I = I + 1
SendKeys Rpt & "%n^c{ESC}", True
Wbk.Worksheets(1).Cells(I + 1, 1).Activate
ActiveSheet.Paste
Macro = ActiveCell.Value
If Macro = ActiveCell.Offset(-1).Value Then
ActiveCell.Clear
Exit Do
End If
SendKeys Rpt & "%t^c{ESC}{ESC}", True
Wbk.Worksheets(1).Cells(I + 1, 2).Activate
ActiveSheet.Paste
Racc = ActiveCell.Value
If Racc <> Macro Then
Wbk.Worksheets(1).Cells(I + 1, 2).Value = "Ctrl-" & Racc
Else
Wbk.Worksheets(1).Cells(I + 1, 2).Clear
End If

Loop

With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub
'======================
FS
--
Frédéric SIGONNEAU
Modules et modèles pour Excel :
http://frederic.sigonneau.free.fr/

Vincent_C a écrit :
bonjour à tous,

pour avoir la liste des macros + les raccourcis clavier, j'utilisais la
macro suivante sous excel 2003 :

Sub ListeMacros()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer

Application.ScreenUpdating = False
Workbooks.Add.Worksheets(1).[A1:B1] = [{"Procédure","Raccourci"}]

SendKeys "%{F8}%a{PGUP}{TAB}{ESC}"

'nécessite une référence à la bibliothèque
'Microsoft Forms 2.0 Object Library
With New DataObject
Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
SendKeys Rpt & "%n^c{ESC}", True
.GetFromClipboard
If Macro = .GetText(1) Then Exit Do
Macro = .GetText(1)
SendKeys Rpt & "%t^c{ESC}{ESC}", True
.GetFromClipboard
Racc = .GetText(1)
I = I + 1
Cells(I + 1, 1) = Macro
If Racc <> Macro Then Cells(I + 1, 2) = "Ctrl-" & Racc
Loop
End With
With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub

dans excel 2007 elle ne fonctionne pas alors que la bibliothèque Microsoft
Forms 2.0 Object Library est bien activée

pouvez vous m'aider s'il vous plait ?

d'avance merci !

bien cordialement,
Vincent_C


Avatar
Vincent_C
Ok merci beaucoup de votre aide et bon week end à vous !

bien cordialement,

Vincent_C

"FS" a écrit :

Bonjour,

Contrairement à mes petits camarades, je n'arrive à faire tourner ce
code (qui est de LL me semble-t-il) avec Excel 2007 ( .GetText(1) ne
passe pas) et il ne fonctionne pas très bien non plus avec Excel 2003
(la récupération des raccourcis clavier ne se fait pas).
Je te propose une autre approche (sans DataObject). Elle semble
fonctionner correctement avec Excel 2007, mais pas avec Excel 2003 (mais
ce n'était pas ta question).
A tester (et à exécuter depuis Excel et non dans l'éditeur VBE) :

'====================== > Sub ListeMacros_2()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer
Dim Wbk As Workbook

' Application.ScreenUpdating = False
Set Wbk = Workbooks.Add
Wbk.Worksheets(1).[A1:B1] = [{"Procédure","Raccourci"}]
SendKeys "%{F8}%a{PGUP}{TAB}{ESC}", True

Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
I = I + 1
SendKeys Rpt & "%n^c{ESC}", True
Wbk.Worksheets(1).Cells(I + 1, 1).Activate
ActiveSheet.Paste
Macro = ActiveCell.Value
If Macro = ActiveCell.Offset(-1).Value Then
ActiveCell.Clear
Exit Do
End If
SendKeys Rpt & "%t^c{ESC}{ESC}", True
Wbk.Worksheets(1).Cells(I + 1, 2).Activate
ActiveSheet.Paste
Racc = ActiveCell.Value
If Racc <> Macro Then
Wbk.Worksheets(1).Cells(I + 1, 2).Value = "Ctrl-" & Racc
Else
Wbk.Worksheets(1).Cells(I + 1, 2).Clear
End If

Loop

With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub
'====================== >
FS
--
Frédéric SIGONNEAU
Modules et modèles pour Excel :
http://frederic.sigonneau.free.fr/

Vincent_C a écrit :
> bonjour à tous,
>
> pour avoir la liste des macros + les raccourcis clavier, j'utilisais la
> macro suivante sous excel 2003 :
>
> Sub ListeMacros()
> Dim Macro As String, Racc As String
> Dim Rpt As String, I As Integer
>
> Application.ScreenUpdating = False
> Workbooks.Add.Worksheets(1).[A1:B1] = [{"Procédure","Raccourci"}]
>
> SendKeys "%{F8}%a{PGUP}{TAB}{ESC}"
>
> 'nécessite une référence à la bibliothèque
> 'Microsoft Forms 2.0 Object Library
> With New DataObject
> Do
> Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
> SendKeys Rpt & "%n^c{ESC}", True
> .GetFromClipboard
> If Macro = .GetText(1) Then Exit Do
> Macro = .GetText(1)
> SendKeys Rpt & "%t^c{ESC}{ESC}", True
> .GetFromClipboard
> Racc = .GetText(1)
> I = I + 1
> Cells(I + 1, 1) = Macro
> If Racc <> Macro Then Cells(I + 1, 2) = "Ctrl-" & Racc
> Loop
> End With
> With Columns("A:B")
> .AutoFit
> .Sort [A1], Header:=xlYes
> .CurrentRegion.AutoFormat xlRangeAutoFormatColor2
> End With
> End Sub
>
> dans excel 2007 elle ne fonctionne pas alors que la bibliothèque Microsoft
> Forms 2.0 Object Library est bien activée
>
> pouvez vous m'aider s'il vous plait ?
>
> d'avance merci !
>
> bien cordialement,
> Vincent_C



Avatar
pier3d
Le vendredi 18 Septembre 2009 à 17:38 par FS :
Bonjour,
Contrairement à mes petits camarades, je n'arrive à faire tourner
ce
code (qui est de LL me semble-t-il) avec Excel 2007 ( .GetText(1) ne
passe pas) et il ne fonctionne pas très bien non plus avec Excel 2003
(la récupération des raccourcis clavier ne se fait pas).
Je te propose une autre approche (sans DataObject). Elle semble
fonctionner correctement avec Excel 2007, mais pas avec Excel 2003 (mais
ce n'était pas ta question).
A tester (et à exécuter depuis Excel et non dans l'éditeur
VBE) :
'====================== Sub ListeMacros_2()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer
Dim Wbk As Workbook
' Application.ScreenUpdating = False
Set Wbk = Workbooks.Add
Wbk.Worksheets(1).[A1:B1] =
[{"Procédure","Raccourci"}]
SendKeys "%{F8}%a{PGUP}{TAB}{ESC}", True
Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
I = I + 1
SendKeys Rpt & "%n^c{ESC}", True
Wbk.Worksheets(1).Cells(I + 1, 1).Activate
ActiveSheet.Paste
Macro = ActiveCell.Value
If Macro = ActiveCell.Offset(-1).Value Then
ActiveCell.Clear
Exit Do
End If
SendKeys Rpt & "%t^c{ESC}{ESC}", True
Wbk.Worksheets(1).Cells(I + 1, 2).Activate
ActiveSheet.Paste
Racc = ActiveCell.Value
If Racc <> Macro Then
Wbk.Worksheets(1).Cells(I + 1, 2).Value = "Ctrl-" & Racc
Else
Wbk.Worksheets(1).Cells(I + 1, 2).Clear
End If
Loop
With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub
'======================
FS
--
Frédéric SIGONNEAU
Modules et modèles pour Excel :
http://frederic.sigonneau.free.fr/
Vincent_C a écrit :
bonjour à tous,
pour avoir la liste des macros + les raccourcis clavier, j'utilisais la
macro suivante sous excel 2003 :
Sub ListeMacros()
Dim Macro As String, Racc As String
Dim Rpt As String, I As Integer
Application.ScreenUpdating = False
Workbooks.Add.Worksheets(1).[A1:B1] =
[{"Procédure","Raccourci"}]
SendKeys "%{F8}%a{PGUP}{TAB}{ESC}"
'nécessite une référence à la bibliothèque
'Microsoft Forms 2.0 Object Library
With New DataObject
Do
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN}", I)
SendKeys Rpt & "%n^c{ESC}", True
.GetFromClipboard
If Macro = .GetText(1) Then Exit Do
Macro = .GetText(1)
SendKeys Rpt & "%t^c{ESC}{ESC}", True
.GetFromClipboard
Racc = .GetText(1)
I = I + 1
Cells(I + 1, 1) = Macro
If Racc <> Macro Then Cells(I + 1, 2) = "Ctrl-" & Racc
Loop
End With
With Columns("A:B")
.AutoFit
.Sort [A1], Header:=xlYes
.CurrentRegion.AutoFormat xlRangeAutoFormatColor2
End With
End Sub
dans excel 2007 elle ne fonctionne pas alors que la bibliothèque
Microsoft
Forms 2.0 Object Library est bien activée
pouvez vous m'aider s'il vous plait ?
d'avance merci !
bien cordialement,
Vincent_C
Il y a une ligne que l'éditeur Vba affiche en rouge :
Rpt = "%{F8}{TAB}" & Application.Rept("{DOWN)
Elle me semble bien suspecte à moi aussi. Ne manque-t-il pas une fermeture d'accolade et de guillemet après le mot DOWN ? De plus, selon l'Aide d'Excel, la méthode Rept exige deux arguments.
Finalement, est-ce que je vous étonnerai si je vous dit que je ne comprends strictement rien à ce code. Et pourtant je programme en Vba d'Excel depuis des années.
Je suis très intrigué et j'aimerais en savoir plus.
Pierre Cloutier