Problème d'ouverture de fichier avec des API

Fermé
Christian_BDD Messages postés 1 Date d'inscription mercredi 17 septembre 2014 Statut Membre Dernière intervention 17 septembre 2014 - 17 sept. 2014 à 11:53
f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 - 17 sept. 2014 à 12:15
Bonjour,

J'ai récemment livré un fichier excel 2010 qui fonctionne correctement sur l'ordinateur de la personne qui a effectué la recette. Celle-ci l'a envoyé à un

collègue (ayant lui aussi excel 2010) qui ne peut pas ouvrir le fichier et qui a le message suivant :
"erreur de compilation dans le module caché (le fichier est protégé): nom_du_module. Cette erreur se produit généralement lorsque le code est incompatible

avec la version, plateforme ou architecture de cette application. Pour plus d'information cliquez sur aide"

Le module en question contient des déclarations API, que je connais mal. Je précise que je n'ai pas créé ce fichier, mais que j'ai effectué des modifications

n'ayant aucun lien avec ce module.

Ci-dessous la programmation API :



Private Declare PtrSafe Function GetSystemMetrics& _
Lib "USER32" (ByVal nIndex&)
Private Declare PtrSafe Function GetForegroundWindow& _
Lib "USER32" ()
Private Declare PtrSafe Function GetWindowRect& _
Lib "USER32" (ByVal hWnd&, lpRect As RECT)
Declare PtrSafe Function GetDesktopWindow Lib "USER32" () As Long
'fonction pour mettre le curseur à un endroit voulu
Declare Function SetCursorPos Lib "USER32" ( _
ByVal X As Long, _
ByVal Y As Long) As Long
' ---API permettant de déplacer la souris---
Declare Sub mouse_event Lib "USER32" (ByVal dwFlags As Long, _
ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)

' ---Définition des constantes---
Global Const MOUSEEVENTF_ABSOLUTE = &H8000
Global Const MOUSEEVENTF_LEFTDOWN = &H2
Global Const MOUSEEVENTF_LEFTUP = &H4
Global Const MOUSEEVENTF_MIDDLEDO = &H20
Global Const MOUSEEVENTF_MIDDLEUP = &H40
Global Const MOUSEEVENTF_MOVE = &H1
Global Const MOUSEEVENTF_RIGHTDOW = &H8
Global Const MOUSEEVENTF_RIGHTUP = &H10

'---Constantes Mot de Passe---
Public Const pwIndicateurs As String = "PW1"
Public Const pwDonnees As String = "PW2"
Public Const pwParametres As String = "PW3"
Public Const pwParametrage_Dotation As String = "PW4"
Public Const pwPlan_D_Action As String = "PW5"
Public Const pwWorkbook As String = "PW6"
Public Const pwVba As String = "PW7"
Public Const pwDonneesGraph As String = "PW8"
Public Const pwSecurite As String = "PW9"


Private Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type

Public Function GetScreenResolution() As String
Dim R As RECT
Dim hWnd As Long
Dim RetVal As Long
hWnd = GetDesktopWindow()
RetVal = GetWindowRect(hWnd, R)
GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)
End Function


Sub Resolution()
Dim Info As String, hWnd As Long, R As RECT
Info = "Résolution écran:" & vbTab _
& GetSystemMetrics(0) & " x " _
& GetSystemMetrics(1) & vbLf
hWnd = GetForegroundWindow
GetWindowRect hWnd, R
'Info = Info & "Fenêtre active:" & vbTab _
'& (R.Right - R.Left) & " x " & R.Bottom - R.Top
Info = Info & vbLf & "Fenêtre Excel:" & vbTab _
& Application.Width * 4 / 3 & " x " & Application.Height * 4 / 3
MsgBox Info
End Sub

Public Sub AutoAjust()
Dim LargeurEcran As Long
Dim HauteurEcran As Long

LargeurEcran = GetSystemMetrics(0)
HauteurEcran = GetSystemMetrics(1)

If HauteurEcran < 850 Then
form_Saisie.Height = 480
form_Saisie.Width = 622
form_Saisie.Zoom = 90
form_Saisie.Left = 40
form_Saisie.Top = 50
End If

End Sub


Malheureusement, je ne connais pas l'environnement exact de l'ordinateur sur lequel le problème s'est posé (mis à part le fait que la version MS installée ne
pose pas problème). En particulier, je ne sais pas si l'ordinateur est un 32 ou un 64 bits.

Est-ce cela le problème, ou autre chose ?


Cordialement.
A voir également:

1 réponse

f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 1 701
17 sept. 2014 à 12:15
Bonjour,
Ce sont les declarations avec ptrsafe pour office2010 64bit qui posent probleme

regardez ce site microsoft pour modifier votre programme:

https://docs.microsoft.com/fr-fr/previous-versions/office/ee691831(v=office.14)?redirectedfrom=MSDN
0