Bonjour,
J'ai une macro VBA Excel qui m'active une fenêtre Windows après certaines
actions... Mon problème est que si cette macro fonctionne très bien sur
les
Windows 98 et Me, elle plante sur les Windows XP. J'ai le message d'erreur
:
<< Erreur 53 : Fichier manquant vba332.dll >>
J'ai donc recherché sur le Web ce fichier mais sans succès... et je ne
sais
d'ailleurs pas si il serait compatible...
Voici ma ligne de déclaration pour le vba332.dll :
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Savez vous comment me tirer d'affaire pour avoir une macro qui puisse
tourner indifféremment sur les machines avec Windows 98, Me et XP ?
Merci d'avance pour votre aide.
--
@+
HD
Bonjour,
J'ai une macro VBA Excel qui m'active une fenêtre Windows après certaines
actions... Mon problème est que si cette macro fonctionne très bien sur
les
Windows 98 et Me, elle plante sur les Windows XP. J'ai le message d'erreur
:
<< Erreur 53 : Fichier manquant vba332.dll >>
J'ai donc recherché sur le Web ce fichier mais sans succès... et je ne
sais
d'ailleurs pas si il serait compatible...
Voici ma ligne de déclaration pour le vba332.dll :
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Savez vous comment me tirer d'affaire pour avoir une macro qui puisse
tourner indifféremment sur les machines avec Windows 98, Me et XP ?
Merci d'avance pour votre aide.
--
@+
HD
Bonjour,
J'ai une macro VBA Excel qui m'active une fenêtre Windows après certaines
actions... Mon problème est que si cette macro fonctionne très bien sur
les
Windows 98 et Me, elle plante sur les Windows XP. J'ai le message d'erreur
:
<< Erreur 53 : Fichier manquant vba332.dll >>
J'ai donc recherché sur le Web ce fichier mais sans succès... et je ne
sais
d'ailleurs pas si il serait compatible...
Voici ma ligne de déclaration pour le vba332.dll :
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Savez vous comment me tirer d'affaire pour avoir une macro qui puisse
tourner indifféremment sur les machines avec Windows 98, Me et XP ?
Merci d'avance pour votre aide.
--
@+
HD
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Re HD;
La compilation conditionnelle est invoquée par le sympbole #.
Option Explicit
'// Déclarations pour Excel97
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" (ByVal hProject As Long _
, ByVal strFunctionName As String _
, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject As Long _
, ByVal strFunctionID As String _
, ByRef lpfnAddressOf As Long) As Long
Sub Exemple()
Const Msg$ = "The address of MyFunction is: "
#If VBA6 Then ' Excel2000 et ultérieur
MsgBox Msg & GetAddress(AddressOf MyFunction), 64
#Else ' Excel97
MsgBox Msg & GetAddress(AddrOf("MyFunction")), 64
#End If
End Sub
Private Function GetAddress&(AddressOf_FunctionName&)
GetAddress = AddressOf_FunctionName
End Function
Private Function MyFunction() As Long
MyFunction = 0
End Function
#If VBA6 Then
#Else
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Public Function AddrOf(CallbackFunctionName As String) As Long
Dim Result&, CurrentVBProject&, strFunctionID As String
Dim AddressOfFunction&, UnicodeFunctionName As String
'* Convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* If the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
Result = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* If the function exists indeed ...
If Result = 0 Then
' *...get a pointer to the callback function based on
' * the strFunctionID argument of the GetFuncID function
Result = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* If we've got the pointer pass it to the result of the function
If Result = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
#End If
"HD" a écrit dans le message de news:
dlsa7n$22ss$Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Re HD;
La compilation conditionnelle est invoquée par le sympbole #.
Option Explicit
'// Déclarations pour Excel97
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" (ByVal hProject As Long _
, ByVal strFunctionName As String _
, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject As Long _
, ByVal strFunctionID As String _
, ByRef lpfnAddressOf As Long) As Long
Sub Exemple()
Const Msg$ = "The address of MyFunction is: "
#If VBA6 Then ' Excel2000 et ultérieur
MsgBox Msg & GetAddress(AddressOf MyFunction), 64
#Else ' Excel97
MsgBox Msg & GetAddress(AddrOf("MyFunction")), 64
#End If
End Sub
Private Function GetAddress&(AddressOf_FunctionName&)
GetAddress = AddressOf_FunctionName
End Function
Private Function MyFunction() As Long
MyFunction = 0
End Function
#If VBA6 Then
#Else
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Public Function AddrOf(CallbackFunctionName As String) As Long
Dim Result&, CurrentVBProject&, strFunctionID As String
Dim AddressOfFunction&, UnicodeFunctionName As String
'* Convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* If the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
Result = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* If the function exists indeed ...
If Result = 0 Then
' *...get a pointer to the callback function based on
' * the strFunctionID argument of the GetFuncID function
Result = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* If we've got the pointer pass it to the result of the function
If Result = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
#End If
"HD" a écrit dans le message de news:
dlsa7n$22ss$
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Re HD;
La compilation conditionnelle est invoquée par le sympbole #.
Option Explicit
'// Déclarations pour Excel97
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" (ByVal hProject As Long _
, ByVal strFunctionName As String _
, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject As Long _
, ByVal strFunctionID As String _
, ByRef lpfnAddressOf As Long) As Long
Sub Exemple()
Const Msg$ = "The address of MyFunction is: "
#If VBA6 Then ' Excel2000 et ultérieur
MsgBox Msg & GetAddress(AddressOf MyFunction), 64
#Else ' Excel97
MsgBox Msg & GetAddress(AddrOf("MyFunction")), 64
#End If
End Sub
Private Function GetAddress&(AddressOf_FunctionName&)
GetAddress = AddressOf_FunctionName
End Function
Private Function MyFunction() As Long
MyFunction = 0
End Function
#If VBA6 Then
#Else
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Public Function AddrOf(CallbackFunctionName As String) As Long
Dim Result&, CurrentVBProject&, strFunctionID As String
Dim AddressOfFunction&, UnicodeFunctionName As String
'* Convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* If the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
Result = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* If the function exists indeed ...
If Result = 0 Then
' *...get a pointer to the callback function based on
' * the strFunctionID argument of the GetFuncID function
Result = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* If we've got the pointer pass it to the result of the function
If Result = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
#End If
"HD" a écrit dans le message de news:
dlsa7n$22ss$Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Michel Pierron a écrit le 21/11/2005 à 12h34 :Re HD;
La compilation conditionnelle est invoquée par le sympbole #.
Option Explicit
'// Déclarations pour Excel97
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" (ByVal hProject As Long _
, ByVal strFunctionName As String _
, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject As Long _
, ByVal strFunctionID As String _
, ByRef lpfnAddressOf As Long) As Long
Sub Exemple()
Const Msg$ = "The address of MyFunction is: "
#If VBA6 Then ' Excel2000 et ultérieur
MsgBox Msg & GetAddress(AddressOf MyFunction), 64
#Else ' Excel97
MsgBox Msg & GetAddress(AddrOf("MyFunction")), 64
#End If
End Sub
Private Function GetAddress&(AddressOf_FunctionName&)
GetAddress = AddressOf_FunctionName
End Function
Private Function MyFunction() As Long
MyFunction = 0
End Function
#If VBA6 Then
#Else
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Public Function AddrOf(CallbackFunctionName As String) As Long
Dim Result&, CurrentVBProject&, strFunctionID As String
Dim AddressOfFunction&, UnicodeFunctionName As String
'* Convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* If the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
Result = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* If the function exists indeed ...
If Result = 0 Then
' *...get a pointer to the callback function based on
' * the strFunctionID argument of the GetFuncID function
Result = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* If we've got the pointer pass it to the result of the function
If Result = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
#End If
"HD" a écrit dans le message de news:
dlsa7n$22ss$Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Bonjour Michel,
dans un précédent post, sur un autre site, vous avez donné
une soluce pour avoir le nom des fenêtres windows actives via macro VB.
J'utilise ce code mais je suis bloqué avec ce message : "file not
found: vba332.dll". Pouvez-vous m'aider svp ?
voici une partie du code que j'utilise :
''Ajouter la fonction:
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Function AddrOf(CallbackFunctionName As String) As Long
Dim aResult As Long, CurrentVBProject As Long, strFunctionID As String
Dim AddressOfFunction As Long, UnicodeFunctionName As String
'* convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* if the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
aResult = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* if the function exists indeed ...
If aResult = 0 Then
' *...get a pointer to the callback function based on
'* the strFunctionID argument of the GetFuncID function
aResult = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* if we've got the pointer pass it to the result of the function
If aResult = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
Sub WinList()
Application.ScreenUpdating = False
Cells.ClearContents
Cells(1, 1) = "CAPTION"
Cells(1, 2) = "VISIBLE"
Range("A1:B1").Font.Bold = True
Range("A2").Select
ActiveWindow.FreezePanes = True
x = 1
''EnumWindows AddressOf EnumWindowsProc, 0
EnumWindows AddrOf("EnumWindowsProc"), 0
Cells.Columns.AutoFit
End Sub
de plus, j'ai en debut de module :
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String _
, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows Lib "user32.dll" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" _
(ByVal hwnd As Long) As Long
Private x&
Private Function EnumWindowsProc&(ByVal hwnd&, ByVal lParam&)
Dim SLength&, Buffer As String, RetVal&
SLength = GetWindowTextLength(hwnd) + 1
If SLength > 1 Then
Buffer = Space(SLength)
RetVal = GetWindowText(hwnd, Buffer, SLength)
x = x + 1
Cells(x, 1) = Left(Buffer, SLength - 1)
Cells(x, 2) = CBool(IsWindowVisible(hwnd))
End If
EnumWindowsProc = 1
End Function
Merci.
Michel Pierron a écrit le 21/11/2005 à 12h34 :
Re HD;
La compilation conditionnelle est invoquée par le sympbole #.
Option Explicit
'// Déclarations pour Excel97
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" (ByVal hProject As Long _
, ByVal strFunctionName As String _
, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject As Long _
, ByVal strFunctionID As String _
, ByRef lpfnAddressOf As Long) As Long
Sub Exemple()
Const Msg$ = "The address of MyFunction is: "
#If VBA6 Then ' Excel2000 et ultérieur
MsgBox Msg & GetAddress(AddressOf MyFunction), 64
#Else ' Excel97
MsgBox Msg & GetAddress(AddrOf("MyFunction")), 64
#End If
End Sub
Private Function GetAddress&(AddressOf_FunctionName&)
GetAddress = AddressOf_FunctionName
End Function
Private Function MyFunction() As Long
MyFunction = 0
End Function
#If VBA6 Then
#Else
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Public Function AddrOf(CallbackFunctionName As String) As Long
Dim Result&, CurrentVBProject&, strFunctionID As String
Dim AddressOfFunction&, UnicodeFunctionName As String
'* Convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* If the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
Result = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* If the function exists indeed ...
If Result = 0 Then
' *...get a pointer to the callback function based on
' * the strFunctionID argument of the GetFuncID function
Result = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* If we've got the pointer pass it to the result of the function
If Result = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
#End If
"HD" a écrit dans le message de news:
dlsa7n$22ss$
Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Bonjour Michel,
dans un précédent post, sur un autre site, vous avez donné
une soluce pour avoir le nom des fenêtres windows actives via macro VB.
J'utilise ce code mais je suis bloqué avec ce message : "file not
found: vba332.dll". Pouvez-vous m'aider svp ?
voici une partie du code que j'utilise :
''Ajouter la fonction:
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Function AddrOf(CallbackFunctionName As String) As Long
Dim aResult As Long, CurrentVBProject As Long, strFunctionID As String
Dim AddressOfFunction As Long, UnicodeFunctionName As String
'* convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* if the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
aResult = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* if the function exists indeed ...
If aResult = 0 Then
' *...get a pointer to the callback function based on
'* the strFunctionID argument of the GetFuncID function
aResult = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:=AddressOfFunction)
'* if we've got the pointer pass it to the result of the function
If aResult = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
Sub WinList()
Application.ScreenUpdating = False
Cells.ClearContents
Cells(1, 1) = "CAPTION"
Cells(1, 2) = "VISIBLE"
Range("A1:B1").Font.Bold = True
Range("A2").Select
ActiveWindow.FreezePanes = True
x = 1
''EnumWindows AddressOf EnumWindowsProc, 0
EnumWindows AddrOf("EnumWindowsProc"), 0
Cells.Columns.AutoFit
End Sub
de plus, j'ai en debut de module :
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String _
, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows Lib "user32.dll" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" _
(ByVal hwnd As Long) As Long
Private x&
Private Function EnumWindowsProc&(ByVal hwnd&, ByVal lParam&)
Dim SLength&, Buffer As String, RetVal&
SLength = GetWindowTextLength(hwnd) + 1
If SLength > 1 Then
Buffer = Space(SLength)
RetVal = GetWindowText(hwnd, Buffer, SLength)
x = x + 1
Cells(x, 1) = Left(Buffer, SLength - 1)
Cells(x, 2) = CBool(IsWindowVisible(hwnd))
End If
EnumWindowsProc = 1
End Function
Merci.
Michel Pierron a écrit le 21/11/2005 à 12h34 :Re HD;
La compilation conditionnelle est invoquée par le sympbole #.
Option Explicit
'// Déclarations pour Excel97
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" (hProject As Long) As Long
Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" (ByVal hProject As Long _
, ByVal strFunctionName As String _
, ByRef strFunctionID As String) As Long
Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" (ByVal hProject As Long _
, ByVal strFunctionID As String _
, ByRef lpfnAddressOf As Long) As Long
Sub Exemple()
Const Msg$ = "The address of MyFunction is: "
#If VBA6 Then ' Excel2000 et ultérieur
MsgBox Msg & GetAddress(AddressOf MyFunction), 64
#Else ' Excel97
MsgBox Msg & GetAddress(AddrOf("MyFunction")), 64
#End If
End Sub
Private Function GetAddress&(AddressOf_FunctionName&)
GetAddress = AddressOf_FunctionName
End Function
Private Function MyFunction() As Long
MyFunction = 0
End Function
#If VBA6 Then
#Else
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Public Function AddrOf(CallbackFunctionName As String) As Long
Dim Result&, CurrentVBProject&, strFunctionID As String
Dim AddressOfFunction&, UnicodeFunctionName As String
'* Convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* If the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
Result = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* If the function exists indeed ...
If Result = 0 Then
' *...get a pointer to the callback function based on
' * the strFunctionID argument of the GetFuncID function
Result = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* If we've got the pointer pass it to the result of the function
If Result = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
#End If
"HD" a écrit dans le message de news:
dlsa7n$22ss$Cette dll n'a pas de rapport avec l'OS utilisé
mais permet l'utilisation de l'opérateur
AddressOf avec Excel97. Tu devrais donc
utiliser la compilation conditionnelle en fonction
de la version d'Excel.
Ouille... Effectivement les postes sous Windows XP ont Excel 2003...
Que veux tu dire par "compilation conditionnelle" ?
Et quelles fonctions et quel dll utiliser pour obtenir les mêmes choses
qu'avec mon bon vieu Excel 97 ?
--
@+
HD
Bonjour Michel,
dans un précédent post, sur un autre site, vous avez donné
une soluce pour avoir le nom des fenêtres windows actives via macro VB.
J'utilise ce code mais je suis bloqué avec ce message : "file not
found: vba332.dll". Pouvez-vous m'aider svp ?
voici une partie du code que j'utilise :
''Ajouter la fonction:
'* AddressOf operator replacement for Office97 VBA
'* Authors: Ken Getz and Michael Kaplan
Function AddrOf(CallbackFunctionName As String) As Long
Dim aResult As Long, CurrentVBProject As Long, strFunctionID As String
Dim AddressOfFunction As Long, UnicodeFunctionName As String
'* convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)
'* if the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'* ...get the function ID of the callback function, based on its
'* unicode-converted name, in order to ensure that it exists
aResult = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, strFunctionID:=strFunctionID)
'* if the function exists indeed ...
If aResult = 0 Then
' *...get a pointer to the callback function based on
'* the strFunctionID argument of the GetFuncID function
aResult = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, lpfnAddressOf:dressOfFunction)
'* if we've got the pointer pass it to the result of the function
If aResult = 0 Then AddrOf = AddressOfFunction
End If
End If
End Function
Sub WinList()
Application.ScreenUpdating = False
Cells.ClearContents
Cells(1, 1) = "CAPTION"
Cells(1, 2) = "VISIBLE"
Range("A1:B1").Font.Bold = True
Range("A2").Select
ActiveWindow.FreezePanes = True
x = 1
''EnumWindows AddressOf EnumWindowsProc, 0
EnumWindows AddrOf("EnumWindowsProc"), 0
Cells.Columns.AutoFit
End Sub
de plus, j'ai en debut de module :
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowText Lib "user32.dll" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String _
, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows Lib "user32.dll" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" _
(ByVal hwnd As Long) As Long
Private x&
Private Function EnumWindowsProc&(ByVal hwnd&, ByVal lParam&)
Dim SLength&, Buffer As String, RetVal&
SLength = GetWindowTextLength(hwnd) + 1
If SLength > 1 Then
Buffer = Space(SLength)
RetVal = GetWindowText(hwnd, Buffer, SLength)
x = x + 1
Cells(x, 1) = Left(Buffer, SLength - 1)
Cells(x, 2) = CBool(IsWindowVisible(hwnd))
End If
EnumWindowsProc = 1
End Function
Merci.