OVH Cloud OVH Cloud

File dialog et file search

3 réponses
Avatar
JAG
Bonjour, merci Raymond pour tes indications sur les dll.
Malheureusement mon prbl=E8me est toujours la et je ne sais=20
le resoudre:
J'ai une appli qui marche dans laquelle, j'utilise file=20
search et filedialog et ca marche niquel . j'en fais un=20
Runtime que j'installe sur un autre poste et la ca ne=20
marche plus
Il reconnait le file search mais d=E8s qu'il lance l=20
recherche, il ne trouve pas le fichier qui pourtant est=20
pr=E9sent=20
ensuite, le file dialog il me renvoie l'erreur :
"Method 'FileDialog' of object '_Application' failed"
je vous mets le code pour ceux que ca interesse :

File dialog:=20

Public Sub Fre_Refresh_Link()
Dim Nbtables As Integer, I As Integer, tmp As=20
TableDefs, tmptable As TableDef, done As Boolean
Dim response As String
Set tmp =3D CurrentDb.TableDefs
Nbtables =3D tmp.Count
=20
=20
Dim Fen As FileDialog
MsgBox "ca rentre dans la fonction", vbOKOnly
Set Fen =3D Application.FileDialog(msoFileDialogOpen)
=20
Fen.InitialFileName =3D "D:\DONNEES"
MsgBox "rech " & Fen.InitialFileName, vbOKOnly
=20
Fen.Filters.Add "Database", "*.mdb", 1
For I =3D 8 To Nbtables - 1
Set tmptable =3D tmp(I)

If tmptable.Attributes =3D dbAttachedTable And=20
tmptable.Connect=20
=3D ";DATABASE=3DD:\SuperFor\BurkinaDorsalV0.3.mdb" Then
If done =3D False Then
MsgBox "attention ca s'affiche!!",=20
vbOKOnly
Fen.Show
MsgBox "attention ca y est c'est=20
affiche!!", vbOKOnly
response =3D Fen.SelectedItems(1)
done =3D True
End If
=20
tmptable.Connect =3D ";DATABASE=3D" & response
tmptable.RefreshLink
End If
Next I
End Sub

file search

Public Sub Fre_Get_Path_Excel_Word()
Dim varItm As Variant, strtmp As String, chemin As String
With Application.FileSearch
.Newsearch
.MatchTextExactly =3D True
chemin =3D "C:\Program Files\Microsoft office\"
.LookIn =3D chemin
MsgBox "voila ou on cherche : " & .LookIn
.FileName =3D "EXCEL.EXE"
.SearchSubFolders =3D True
=20
If .Execute() > 0 Then
FrePathExcel =3D .FoundFiles(1)
MsgBox "path excel marche " & FrePathExcel,=20
vbOKOnly, "test"
Else
FrePathExcel =3D "C:\Progarm Files\Microsoft=20
Office\Office\EXCEL.EXE"
MsgBox "path excel marche pas ", vbOKOnly, "test"
End If

.Newsearch
.LookIn =3D chemin
.FileName =3D "WINWORD.EXE"
.SearchSubFolders =3D True
If .Execute() > 0 Then
FrePathWord =3D .FoundFiles(1)
MsgBox "path word marche" & FrePathWord,=20
vbOKOnly, "test"
Else
FrePathWord =3D "C:\Program Files\Microsoft=20
Office\Office\WINWORD.EXE"
MsgBox "path word marche pas ", vbOKOnly, "test"
End If
=20
End With
End Sub


merci de m'avoir lu et bonne apr=E8s midi

3 réponses

Avatar
Benoit Compoint [MS]
Bonjour,

La méthode FileDialog ne fonctionne pas avec le runtime d'Access 2002.
Ce problème est décrit dans l'article technique 510291 (allemand) de la base
de connaissances Microsoft :
http://support.microsoft.com/default.aspx?scid=KB;DE;510291

Cet article fournit comme solution le code source VBA d'une fonction
"OpenDialog" qui fait appel à la fonction API GetOpenFileName.

Benoit Compoint.

"JAG" wrote in message
news:4b2601c3e4da$a1c595b0$
Bonjour, merci Raymond pour tes indications sur les dll.
Malheureusement mon prblème est toujours la et je ne sais
le resoudre:
J'ai une appli qui marche dans laquelle, j'utilise file
search et filedialog et ca marche niquel . j'en fais un
Runtime que j'installe sur un autre poste et la ca ne
marche plus
Il reconnait le file search mais dès qu'il lance l
recherche, il ne trouve pas le fichier qui pourtant est
présent
ensuite, le file dialog il me renvoie l'erreur :
"Method 'FileDialog' of object '_Application' failed"
je vous mets le code pour ceux que ca interesse :

File dialog:

Public Sub Fre_Refresh_Link()
Dim Nbtables As Integer, I As Integer, tmp As
TableDefs, tmptable As TableDef, done As Boolean
Dim response As String
Set tmp = CurrentDb.TableDefs
Nbtables = tmp.Count


Dim Fen As FileDialog
MsgBox "ca rentre dans la fonction", vbOKOnly
Set Fen = Application.FileDialog(msoFileDialogOpen)

Fen.InitialFileName = "D:DONNEES"
MsgBox "rech " & Fen.InitialFileName, vbOKOnly

Fen.Filters.Add "Database", "*.mdb", 1
For I = 8 To Nbtables - 1
Set tmptable = tmp(I)

If tmptable.Attributes = dbAttachedTable And
tmptable.Connect
= ";DATABASE=D:SuperForBurkinaDorsalV0.3.mdb" Then
If done = False Then
MsgBox "attention ca s'affiche!!",
vbOKOnly
Fen.Show
MsgBox "attention ca y est c'est
affiche!!", vbOKOnly
response = Fen.SelectedItems(1)
done = True
End If

tmptable.Connect = ";DATABASE=" & response
tmptable.RefreshLink
End If
Next I
End Sub

file search

Public Sub Fre_Get_Path_Excel_Word()
Dim varItm As Variant, strtmp As String, chemin As String
With Application.FileSearch
.Newsearch
.MatchTextExactly = True
chemin = "C:Program FilesMicrosoft office"
.LookIn = chemin
MsgBox "voila ou on cherche : " & .LookIn
.FileName = "EXCEL.EXE"
.SearchSubFolders = True

If .Execute() > 0 Then
FrePathExcel = .FoundFiles(1)
MsgBox "path excel marche " & FrePathExcel,
vbOKOnly, "test"
Else
FrePathExcel = "C:Progarm FilesMicrosoft
OfficeOfficeEXCEL.EXE"
MsgBox "path excel marche pas ", vbOKOnly, "test"
End If

.Newsearch
.LookIn = chemin
.FileName = "WINWORD.EXE"
.SearchSubFolders = True
If .Execute() > 0 Then
FrePathWord = .FoundFiles(1)
MsgBox "path word marche" & FrePathWord,
vbOKOnly, "test"
Else
FrePathWord = "C:Program FilesMicrosoft
OfficeOfficeWINWORD.EXE"
MsgBox "path word marche pas ", vbOKOnly, "test"
End If

End With
End Sub


merci de m'avoir lu et bonne après midi
Avatar
Merci beaucoup et pour le filesearch une idée peut etre?
-----Message d'origine-----
Bonjour,

La méthode FileDialog ne fonctionne pas avec le runtime
d'Access 2002.

Ce problème est décrit dans l'article technique 510291
(allemand) de la base

de connaissances Microsoft :
http://support.microsoft.com/default.aspx?
scid=KB;DE;510291


Cet article fournit comme solution le code source VBA
d'une fonction

"OpenDialog" qui fait appel à la fonction API
GetOpenFileName.


Benoit Compoint.

"JAG" wrote in
message

news:4b2601c3e4da$a1c595b0$
Bonjour, merci Raymond pour tes indications sur les dll.
Malheureusement mon prblème est toujours la et je ne sais
le resoudre:
J'ai une appli qui marche dans laquelle, j'utilise file
search et filedialog et ca marche niquel . j'en fais un
Runtime que j'installe sur un autre poste et la ca ne
marche plus
Il reconnait le file search mais dès qu'il lance l
recherche, il ne trouve pas le fichier qui pourtant est
présent
ensuite, le file dialog il me renvoie l'erreur :
"Method 'FileDialog' of object '_Application' failed"
je vous mets le code pour ceux que ca interesse :

File dialog:

Public Sub Fre_Refresh_Link()
Dim Nbtables As Integer, I As Integer, tmp As
TableDefs, tmptable As TableDef, done As Boolean
Dim response As String
Set tmp = CurrentDb.TableDefs
Nbtables = tmp.Count


Dim Fen As FileDialog
MsgBox "ca rentre dans la fonction", vbOKOnly
Set Fen = Application.FileDialog(msoFileDialogOpen)

Fen.InitialFileName = "D:DONNEES"
MsgBox "rech " & Fen.InitialFileName, vbOKOnly

Fen.Filters.Add "Database", "*.mdb", 1
For I = 8 To Nbtables - 1
Set tmptable = tmp(I)

If tmptable.Attributes = dbAttachedTable And
tmptable.Connect
= ";DATABASE=D:SuperForBurkinaDorsalV0.3.mdb" Then
If done = False Then
MsgBox "attention ca s'affiche!!",
vbOKOnly
Fen.Show
MsgBox "attention ca y est c'est
affiche!!", vbOKOnly
response = Fen.SelectedItems(1)
done = True
End If

tmptable.Connect = ";DATABASE=" & response
tmptable.RefreshLink
End If
Next I
End Sub

file search

Public Sub Fre_Get_Path_Excel_Word()
Dim varItm As Variant, strtmp As String, chemin As String
With Application.FileSearch
.Newsearch
.MatchTextExactly = True
chemin = "C:Program FilesMicrosoft office"
.LookIn = chemin
MsgBox "voila ou on cherche : " & .LookIn
.FileName = "EXCEL.EXE"
.SearchSubFolders = True

If .Execute() > 0 Then
FrePathExcel = .FoundFiles(1)
MsgBox "path excel marche " & FrePathExcel,
vbOKOnly, "test"
Else
FrePathExcel = "C:Progarm FilesMicrosoft
OfficeOfficeEXCEL.EXE"
MsgBox "path excel marche pas ", vbOKOnly, "test"
End If

.Newsearch
.LookIn = chemin
.FileName = "WINWORD.EXE"
.SearchSubFolders = True
If .Execute() > 0 Then
FrePathWord = .FoundFiles(1)
MsgBox "path word marche" & FrePathWord,
vbOKOnly, "test"
Else
FrePathWord = "C:Program FilesMicrosoft
OfficeOfficeWINWORD.EXE"
MsgBox "path word marche pas ", vbOKOnly, "test"
End If

End With
End Sub


merci de m'avoir lu et bonne après midi


.



Avatar
Benoit Compoint [MS]
Bonsoir,

Pour effectuer une recherche incluant les sous-dossiers, vous pouvez
utiliser l'une des deux méthodes décrites dans l'article technique 468461 de
la base de connaissances Microsoft :

1. Utilisation de l'API Windows
2. Utilisation de la fonction Dir

http://support.microsoft.com/default.aspx?scid=KB;FR;468461

Vous pouvez aussi utilisez une 3ème méthode décrite dans l'article 185601 :
Utilisation du FileSystemObject.

http://support.microsoft.com/default.aspx?scid=KB;EN-US;185601

Benoit Compoint

wrote in message
news:516701c3e4df$ddd8f8d0$
Merci beaucoup et pour le filesearch une idée peut etre?
-----Message d'origine-----
Bonjour,

La méthode FileDialog ne fonctionne pas avec le runtime
d'Access 2002.

Ce problème est décrit dans l'article technique 510291
(allemand) de la base

de connaissances Microsoft :
http://support.microsoft.com/default.aspx?
scid=KB;DE;510291


Cet article fournit comme solution le code source VBA
d'une fonction

"OpenDialog" qui fait appel à la fonction API
GetOpenFileName.


Benoit Compoint.

"JAG" wrote in
message

news:4b2601c3e4da$a1c595b0$
Bonjour, merci Raymond pour tes indications sur les dll.
Malheureusement mon prblème est toujours la et je ne sais
le resoudre:
J'ai une appli qui marche dans laquelle, j'utilise file
search et filedialog et ca marche niquel . j'en fais un
Runtime que j'installe sur un autre poste et la ca ne
marche plus
Il reconnait le file search mais dès qu'il lance l
recherche, il ne trouve pas le fichier qui pourtant est
présent
ensuite, le file dialog il me renvoie l'erreur :
"Method 'FileDialog' of object '_Application' failed"
je vous mets le code pour ceux que ca interesse :

File dialog:

Public Sub Fre_Refresh_Link()
Dim Nbtables As Integer, I As Integer, tmp As
TableDefs, tmptable As TableDef, done As Boolean
Dim response As String
Set tmp = CurrentDb.TableDefs
Nbtables = tmp.Count


Dim Fen As FileDialog
MsgBox "ca rentre dans la fonction", vbOKOnly
Set Fen = Application.FileDialog(msoFileDialogOpen)

Fen.InitialFileName = "D:DONNEES"
MsgBox "rech " & Fen.InitialFileName, vbOKOnly

Fen.Filters.Add "Database", "*.mdb", 1
For I = 8 To Nbtables - 1
Set tmptable = tmp(I)

If tmptable.Attributes = dbAttachedTable And
tmptable.Connect
= ";DATABASE=D:SuperForBurkinaDorsalV0.3.mdb" Then
If done = False Then
MsgBox "attention ca s'affiche!!",
vbOKOnly
Fen.Show
MsgBox "attention ca y est c'est
affiche!!", vbOKOnly
response = Fen.SelectedItems(1)
done = True
End If

tmptable.Connect = ";DATABASE=" & response
tmptable.RefreshLink
End If
Next I
End Sub

file search

Public Sub Fre_Get_Path_Excel_Word()
Dim varItm As Variant, strtmp As String, chemin As String
With Application.FileSearch
.Newsearch
.MatchTextExactly = True
chemin = "C:Program FilesMicrosoft office"
.LookIn = chemin
MsgBox "voila ou on cherche : " & .LookIn
.FileName = "EXCEL.EXE"
.SearchSubFolders = True

If .Execute() > 0 Then
FrePathExcel = .FoundFiles(1)
MsgBox "path excel marche " & FrePathExcel,
vbOKOnly, "test"
Else
FrePathExcel = "C:Progarm FilesMicrosoft
OfficeOfficeEXCEL.EXE"
MsgBox "path excel marche pas ", vbOKOnly, "test"
End If

.Newsearch
.LookIn = chemin
.FileName = "WINWORD.EXE"
.SearchSubFolders = True
If .Execute() > 0 Then
FrePathWord = .FoundFiles(1)
MsgBox "path word marche" & FrePathWord,
vbOKOnly, "test"
Else
FrePathWord = "C:Program FilesMicrosoft
OfficeOfficeWINWORD.EXE"
MsgBox "path word marche pas ", vbOKOnly, "test"
End If

End With
End Sub


merci de m'avoir lu et bonne après midi


.