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

Impossible d'exécuter un code dans acces

4 réponses
Avatar
jc
Bonjour,

j'ai le code suivant me permettant d'ouvrir un fichier dans access :


Option Compare Database

Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Function GetDirectory(Optional Msg) As String

Dim bInfo As BROWSEINFO
Dim path As String
Dim R As Long, X As Long, Pos As Integer

bInfo.pidlRoot =3D 0

If IsMissing(Msg) Then
bInfo.lpszTitle =3D "Choisir le fichier."
Else
bInfo.lpszTitle =3D Msg
End If

bInfo.ulFlags =3D &H1

X =3D SHBrowseForFolder(bInfo)

path =3D Space$(512)
R =3D SHGetPathFromIDList(ByVal X, ByVal path)

If R Then
Pos =3D InStr(path, Chr$(0))
GetDirectory =3D Left(path, Pos - 1)
Else
GetDirectory =3D ""
End If

End Function


J'arrive =E0 faire fonctionner ce module mais pas =E0 l'incorporer dans un
formulaire

Comment faire ???

merci

4 réponses

Avatar
3stone
Salut,


Tu dis :
J'arrive à faire fonctionner ce module mais pas à l'incorporer dans un
formulaire




Bizarre... comment tu le fais fonctionner, dans ce cas ;-)

Colle le dans un module et tu pourras l'appeler de n'importe où...

--
A+
Pierre (3stone) Access MVP
Perso: http://www.3stone.be/
MPFA: http://www.mpfa.info/ (infos générales)





jc wrote:
Bonjour,

j'ai le code suivant me permettant d'ouvrir un fichier dans access :


Option Compare Database

Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long

Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Function GetDirectory(Optional Msg) As String

Dim bInfo As BROWSEINFO
Dim path As String
Dim R As Long, X As Long, Pos As Integer

bInfo.pidlRoot = 0

If IsMissing(Msg) Then
bInfo.lpszTitle = "Choisir le fichier."
Else
bInfo.lpszTitle = Msg
End If

bInfo.ulFlags = &H1

X = SHBrowseForFolder(bInfo)

path = Space$(512)
R = SHGetPathFromIDList(ByVal X, ByVal path)

If R Then
Pos = InStr(path, Chr$(0))
GetDirectory = Left(path, Pos - 1)
Else
GetDirectory = ""
End If

End Function


J'arrive à faire fonctionner ce module mais pas à l'incorporer dans un
formulaire

Comment faire ???

merci


Avatar
MINOT gilles
On 30 août, 17:31, "3stone" wrote:
Salut,

Tu dis :

> J'arrive à faire fonctionner ce module mais pas à l'incorporer dans un
> formulaire

Bizarre... comment tu le fais fonctionner, dans ce cas ;-)

Colle le dans un module et tu pourras l'appeler de n'importe où...

--
A+
Pierre (3stone) Access MVP
Perso:http://www.3stone.be/
MPFA:http://www.mpfa.info/ (infos générales)



jc wrote:
> Bonjour,

> j'ai le code suivant me permettant d'ouvrir un fichier dans access :

> Option Compare Database

> Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
>     Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
>     ByVal pszPath As String) As Long

> Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
>     Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

> Public Type BROWSEINFO
>     hOwner As Long
>     pidlRoot As Long
>     pszDisplayName As String
>     lpszTitle As String
>     ulFlags As Long
>     lpfn As Long
>     lParam As Long
>     iImage As Long
> End Type

> Function GetDirectory(Optional Msg) As String

> Dim bInfo As BROWSEINFO
> Dim path As String
> Dim R As Long, X As Long, Pos As Integer

> bInfo.pidlRoot = 0

> If IsMissing(Msg) Then
>      bInfo.lpszTitle = "Choisir le fichier."
> Else
>      bInfo.lpszTitle = Msg
> End If

> bInfo.ulFlags = &H1

> X = SHBrowseForFolder(bInfo)

> path = Space$(512)
> R = SHGetPathFromIDList(ByVal X, ByVal path)

> If R Then
>     Pos = InStr(path, Chr$(0))
>      GetDirectory = Left(path, Pos - 1)
> Else
>      GetDirectory = ""
> End If

> End Function

> J'arrive à faire fonctionner ce module mais pas à l'incorporer dans un
> formulaire

> Comment faire ???

> merci- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -



une fois que tu as colle dans un module .dans ton formulaire tu cree
un bouton et sur l'evenement clik unee procedure evenementiel tu
colles :

GetDirectory


A plus
Avatar
Gilbert
Bonjour,

Pour appeler cette fonction d'un formulaire, il te faut la déclarer
publique:

Public Function GetDirectory(Optional Msg) As String
...
...
...
End Function

--
Cordialement,

Gilbert


"MINOT gilles" a écrit dans le message de
news:
On 30 août, 17:31, "3stone" wrote:
Salut,

Tu dis :

> J'arrive à faire fonctionner ce module mais pas à l'incorporer dans un
> formulaire

Bizarre... comment tu le fais fonctionner, dans ce cas ;-)

Colle le dans un module et tu pourras l'appeler de n'importe où...

--
A+
Pierre (3stone) Access MVP
Perso:http://www.3stone.be/
MPFA:http://www.mpfa.info/ (infos générales)



jc wrote:
> Bonjour,

> j'ai le code suivant me permettant d'ouvrir un fichier dans access :

> Option Compare Database

> Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
> Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
> ByVal pszPath As String) As Long

> Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
> Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

> Public Type BROWSEINFO
> hOwner As Long
> pidlRoot As Long
> pszDisplayName As String
> lpszTitle As String
> ulFlags As Long
> lpfn As Long
> lParam As Long
> iImage As Long
> End Type

> Function GetDirectory(Optional Msg) As String

> Dim bInfo As BROWSEINFO
> Dim path As String
> Dim R As Long, X As Long, Pos As Integer

> bInfo.pidlRoot = 0

> If IsMissing(Msg) Then
> bInfo.lpszTitle = "Choisir le fichier."
> Else
> bInfo.lpszTitle = Msg
> End If

> bInfo.ulFlags = &H1

> X = SHBrowseForFolder(bInfo)

> path = Space$(512)
> R = SHGetPathFromIDList(ByVal X, ByVal path)

> If R Then
> Pos = InStr(path, Chr$(0))
> GetDirectory = Left(path, Pos - 1)
> Else
> GetDirectory = ""
> End If

> End Function

> J'arrive à faire fonctionner ce module mais pas à l'incorporer dans un
> formulaire

> Comment faire ???

> merci- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -



une fois que tu as colle dans un module .dans ton formulaire tu cree
un bouton et sur l'evenement clik unee procedure evenementiel tu
colles :

GetDirectory


A plus
Avatar
MINOT gilles
On 30 août, 20:27, "Gilbert" wrote:
Bonjour,

Pour appeler cette fonction d'un formulaire, il te faut la déclarer
publique:

Public Function GetDirectory(Optional Msg) As String
...
...
...
End Function

--
Cordialement,

Gilbert

"MINOT gilles" a écrit dans le message denews:81c04c8
On 30 août, 17:31, "3stone" wrote:





> Salut,

> Tu dis :

> > J'arrive à faire fonctionner ce module mais pas à l'incorporer da ns un
> > formulaire

> Bizarre... comment tu le fais fonctionner, dans ce cas ;-)

> Colle le dans un module et tu pourras l'appeler de n'importe où...

> --
> A+
> Pierre (3stone) Access MVP
> Perso:http://www.3stone.be/
> MPFA:http://www.mpfa.info/(infos générales)

> jc wrote:
> > Bonjour,

> > j'ai le code suivant me permettant d'ouvrir un fichier dans access :

> > Option Compare Database

> > Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
> > Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
> > ByVal pszPath As String) As Long

> > Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
> > Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

> > Public Type BROWSEINFO
> > hOwner As Long
> > pidlRoot As Long
> > pszDisplayName As String
> > lpszTitle As String
> > ulFlags As Long
> > lpfn As Long
> > lParam As Long
> > iImage As Long
> > End Type

> > Function GetDirectory(Optional Msg) As String

> > Dim bInfo As BROWSEINFO
> > Dim path As String
> > Dim R As Long, X As Long, Pos As Integer

> > bInfo.pidlRoot = 0

> > If IsMissing(Msg) Then
> > bInfo.lpszTitle = "Choisir le fichier."
> > Else
> > bInfo.lpszTitle = Msg
> > End If

> > bInfo.ulFlags = &H1

> > X = SHBrowseForFolder(bInfo)

> > path = Space$(512)
> > R = SHGetPathFromIDList(ByVal X, ByVal path)

> > If R Then
> > Pos = InStr(path, Chr$(0))
> > GetDirectory = Left(path, Pos - 1)
> > Else
> > GetDirectory = ""
> > End If

> > End Function

> > J'arrive à faire fonctionner ce module mais pas à l'incorporer da ns un
> > formulaire

> > Comment faire ???

> > merci- Masquer le texte des messages précédents -

> - Afficher le texte des messages précédents -

une fois que tu as colle dans un module .dans ton formulaire tu cree
un bouton et sur l'evenement clik unee procedure evenementiel tu
colles :

GetDirectory

A plus- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -



pour appeler une fonction d'un module , elle n'a pas besoin d'etre
public contrairement a une variable

plus