Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis revenir à
mon application
Comment faire ? Merci
Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis revenir à
mon application
Comment faire ? Merci
Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis revenir à
mon application
Comment faire ? Merci
"Bernard Hector" a écrit dans le
message de news:Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis revenir à
mon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type de
fichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
"Bernard Hector" <BernardHector@discussions.microsoft.com> a écrit dans le
message de news:E5B0D574-6514-451A-96A5-7C72D63ED703@microsoft.com...
Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis revenir à
mon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type de
fichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
"Bernard Hector" a écrit dans le
message de news:Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis revenir à
mon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type de
fichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
Merci, ça marche
Mais comment faire pour ouvrir le fichier sélectionné dans son
application.
Je peux le faire avec par exemple l'instruction W_Appli.Documents.Open
(Fich)
sauf que je dois repérer le type de fichier avant de choisir la bonne
application. Et je ne peux lancer que des fichiers de la suite MsOffice.
Si
je veux lancer un PDF ?
Merci de l'aide
Bonjour,
"Bernard Hector" a écrit dans
le
message de news:Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis
revenir à
mon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type
de
fichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier
sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
Merci, ça marche
Mais comment faire pour ouvrir le fichier sélectionné dans son
application.
Je peux le faire avec par exemple l'instruction W_Appli.Documents.Open
(Fich)
sauf que je dois repérer le type de fichier avant de choisir la bonne
application. Et je ne peux lancer que des fichiers de la suite MsOffice.
Si
je veux lancer un PDF ?
Merci de l'aide
Bonjour,
"Bernard Hector" <BernardHector@discussions.microsoft.com> a écrit dans
le
message de news:E5B0D574-6514-451A-96A5-7C72D63ED703@microsoft.com...
Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis
revenir à
mon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type
de
fichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier
sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
Merci, ça marche
Mais comment faire pour ouvrir le fichier sélectionné dans son
application.
Je peux le faire avec par exemple l'instruction W_Appli.Documents.Open
(Fich)
sauf que je dois repérer le type de fichier avant de choisir la bonne
application. Et je ne peux lancer que des fichiers de la suite MsOffice.
Si
je veux lancer un PDF ?
Merci de l'aide
Bonjour,
"Bernard Hector" a écrit dans
le
message de news:Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis
revenir à
mon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type
de
fichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier
sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
"Bernard Hector" a écrit dans le
message de news:Merci, ça marche
Mais comment faire pour ouvrir le fichier sélectionné dans son
application.Je peux le faire avec par exemple l'instruction W_Appli.Documents.Open
(Fich)sauf que je dois repérer le type de fichier avant de choisir la bonne
application. Et je ne peux lancer que des fichiers de la suite MsOffice.
Sije veux lancer un PDF ?
Merci de l'aide
Bonjour,
peut-être avec l'api ShellExecute
module:
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (_
ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" Alias
"GetDesktopWindow" () As Long
formulaire:
Function StartDoc (DocName As String) as long
Dim Scr_hDC as long
Scr_hDC = GetDesktopWindow ()
'change "Open" to "Explore" to bring up file explorer
StartDoc = ShellExecute (Scr_hDC, "Open", DocName, "", "C:", 1)
end function
'Place the following code in under a command button or in a menu, etc...
dim r as long
r = startdoc ("C:windowsarcade.bmp")
à adapter
Alfred
"Bernard Hector" a écrit dans
lemessage de news:Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis
revenir àmon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type
defichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier
sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
"Bernard Hector" <BernardHector@discussions.microsoft.com> a écrit dans le
message de news:602ED51F-2B47-4035-BEA6-51F65A0BFB3A@microsoft.com...
Merci, ça marche
Mais comment faire pour ouvrir le fichier sélectionné dans son
application.
Je peux le faire avec par exemple l'instruction W_Appli.Documents.Open
(Fich)
sauf que je dois repérer le type de fichier avant de choisir la bonne
application. Et je ne peux lancer que des fichiers de la suite MsOffice.
Si
je veux lancer un PDF ?
Merci de l'aide
Bonjour,
peut-être avec l'api ShellExecute
module:
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (_
ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" Alias
"GetDesktopWindow" () As Long
formulaire:
Function StartDoc (DocName As String) as long
Dim Scr_hDC as long
Scr_hDC = GetDesktopWindow ()
'change "Open" to "Explore" to bring up file explorer
StartDoc = ShellExecute (Scr_hDC, "Open", DocName, "", "C:", 1)
end function
'Place the following code in under a command button or in a menu, etc...
dim r as long
r = startdoc ("C:windowsarcade.bmp")
à adapter
Alfred
"Bernard Hector" <BernardHector@discussions.microsoft.com> a écrit dans
le
message de news:E5B0D574-6514-451A-96A5-7C72D63ED703@microsoft.com...
Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis
revenir à
mon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type
de
fichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier
sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred
"Bernard Hector" a écrit dans le
message de news:Merci, ça marche
Mais comment faire pour ouvrir le fichier sélectionné dans son
application.Je peux le faire avec par exemple l'instruction W_Appli.Documents.Open
(Fich)sauf que je dois repérer le type de fichier avant de choisir la bonne
application. Et je ne peux lancer que des fichiers de la suite MsOffice.
Sije veux lancer un PDF ?
Merci de l'aide
Bonjour,
peut-être avec l'api ShellExecute
module:
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (_
ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As
Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" Alias
"GetDesktopWindow" () As Long
formulaire:
Function StartDoc (DocName As String) as long
Dim Scr_hDC as long
Scr_hDC = GetDesktopWindow ()
'change "Open" to "Explore" to bring up file explorer
StartDoc = ShellExecute (Scr_hDC, "Open", DocName, "", "C:", 1)
end function
'Place the following code in under a command button or in a menu, etc...
dim r as long
r = startdoc ("C:windowsarcade.bmp")
à adapter
Alfred
"Bernard Hector" a écrit dans
lemessage de news:Bonjour
Je souhaiterais accéder à l'explorateur Windows depuis une application
Access : pouvoir ouvrir les fichiers d'un répertoire donné, puis
revenir àmon application
Comment faire ? Merci
Bonjour,
Tu peux essayer ceci :
1- créer un module : OpenFileN contenant:
Option Compare Database
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public lReturn As Long
Public OpenFile As OPENFILENAME
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function LaunchCD(strform As Form) As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "Aucun fichier sélectionné!", vbInformation, _
"Importation"
Else
LaunchCD = Trim(Left(OpenFile.lpstrFile, InStr(1,
OpenFile.lpstrFile, vbNullChar) - 1))
End If
End Function
Public Function GetDirectory(sNewFullPath As String)
Dim iPos As Integer
Dim iCounter As Integer
Dim msPath As String
Dim msFile As String
Dim msFullPath As String
msFullPath = sNewFullPath
msPath = ""
msFile = ""
If Right$(msFullPath, 1) = "/" Or _
Right$(msFullPath, 1) = "" Or _
InStr(1, msFullPath, ".") = 0 Then
'No file specified in this path
msFile = ""
msPath = msFullPath
'Append a backslash if one does not exist
If Right$(msPath, 1) <> "/" And _
Right$(msPath, 1) <> "" Then
msPath = msPath & ""
End If
Else
iPos = Len(msFullPath)
'Loop backwards through msFullPath _
'until we have all of the filename
For iCounter = iPos To 1 Step -1
If Mid$(msFullPath, iCounter, 1) = "/" _
Or Mid$(msFullPath, iCounter, 1) = "" Then
'No more characters for the file
Exit For
Else
msFile = Mid$(msFullPath, _
iCounter, 1) & msFile
End If
Next
'Parse out the path without the filename
msPath = Left$(msFullPath, _
Len(msFullPath) - Len(msFile))
End If
GetDirectory = msPath
End Function
2- mettre dans un button_click d'un formulaire :
Private Sub cmdOpen_Click()
Dim sFilter As String
OpenFile.lpstrInitialDir = ' répertoire par défaut
sFilter = "Fichiers Excel (*.xls)" & Chr(0) & "*.xls" ' choix type
defichiers
OpenFile.lpstrFilter = sFilter
OpenFile.lpstrTitle = "Ouvrir ..."
Texte4 = LaunchCD(Me) ' text4 contient le chemin du fichier
sélectionné
End Sub
bien sûr le code est à adapter à tes besoins ...
Alfred