est ce que qq un pourrait m'aider =E0 r=E9soudre le pb suivant
j'execute la macro suivante
Private Function ChoisirDossier()
Dim objShell, objFolder, chemin, SecuriteSlash As Object
=20
Set objShell =3D CreateObject("objShell.application")
Set objFolder =3D _
objShell.BrowseForFolder(&H0&, "Choisisser un=20
r=E9pertoire", &H1&)
On Error Resume Next
chemin =3D objFolder.ParentFolder.ParseName
(objFolder.Title).Path & ""
If objFolder.Title =3D "Bureau" Then
chemin =3D "C:\Windows\Bureau"
End If
If objFolder.Title =3D "" Then
chemin =3D ""
End If
SecuriteSlash =3D InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then
chemin =3D Mid(objFolder.Title, SecuriteSlash - 1,=20
2) & ""
End If
ChoisirDossier =3D chemin
End Function
mais au moment du d=E9bogage j'ai une erreur=20
"Un composant ActiveX ne peut pas cr=E9er l'objet ou fournir=20
une r=E9f=E9rence =E0 cet objet (erreur 429)"
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Starwing
Essaie ça:
Ça vient de Frédéric Sigonneau:
Sub essai1212() choix = ChoixDossierFichier("d: 9OfficeVBA",1) '<- ici le chemin de ton choix If choix <> "" Then MsgBox choix End Sub
Function ChoixDossierFichier(Racine, Optional SelType As Byte = 0) Dim objShell, objFolder, Chemin, SecuriteSlash, FlagChoix&, Msg$
If SelType = 0 Then FlagChoix = &H1&: Msg = "Choisissez un dossier :" Else FlagChoix = &H4000&: Msg = "Choisissez un fichier :" End If
Set objShell = CreateObject("Shell.Application") 'le troisième paramètre permet de choisir 'la sélection d'un dossier ou d'un fichier (0 ou 1) 'le dernier paramètre permet de choisir le dossier racine Set objFolder = objShell.BrowseForFolder(&H0&, Msg, FlagChoix, Racine) On Error Resume Next Chemin = objFolder.ParentFolder.ParseName (objFolder.Title).path & "" If objFolder.Title = "Bureau" Then Chemin = "C:WindowsBureau" End If If objFolder.Title = "" Then Chemin = "" End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then Chemin = Mid(objFolder.Title, SecuriteSlash - 1, 2) & "" End If ChoixDossierFichier = Chemin End Function
Starwing
-----Message d'origine----- bonjour
est ce que qq un pourrait m'aider à résoudre le pb suivant
j'execute la macro suivante Private Function ChoisirDossier() Dim objShell, objFolder, chemin, SecuriteSlash As Object
Set objShell = CreateObject("objShell.application") Set objFolder = _ objShell.BrowseForFolder(&H0&, "Choisisser un répertoire", &H1&) On Error Resume Next chemin = objFolder.ParentFolder.ParseName (objFolder.Title).Path & "" If objFolder.Title = "Bureau" Then chemin = "C:WindowsBureau" End If If objFolder.Title = "" Then chemin = "" End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then chemin = Mid(objFolder.Title, SecuriteSlash - 1, 2) & "" End If ChoisirDossier = chemin End Function
mais au moment du débogage j'ai une erreur "Un composant ActiveX ne peut pas créer l'objet ou fournir
une référence à cet objet (erreur 429)"
comment faire pour résoudre ce pb
merci par avance .
Essaie ça:
Ça vient de Frédéric Sigonneau:
Sub essai1212()
choix = ChoixDossierFichier("d: 9OfficeVBA",1) '<-
ici le chemin de ton
choix
If choix <> "" Then MsgBox choix
End Sub
Function ChoixDossierFichier(Racine, Optional SelType As
Byte = 0)
Dim objShell, objFolder, Chemin, SecuriteSlash,
FlagChoix&, Msg$
If SelType = 0 Then
FlagChoix = &H1&: Msg = "Choisissez un dossier :"
Else
FlagChoix = &H4000&: Msg = "Choisissez un fichier :"
End If
Set objShell = CreateObject("Shell.Application")
'le troisième paramètre permet de choisir
'la sélection d'un dossier ou d'un fichier (0 ou 1)
'le dernier paramètre permet de choisir le dossier
racine
Set objFolder = objShell.BrowseForFolder(&H0&, Msg,
FlagChoix, Racine)
On Error Resume Next
Chemin = objFolder.ParentFolder.ParseName
(objFolder.Title).path & ""
If objFolder.Title = "Bureau" Then
Chemin = "C:WindowsBureau"
End If
If objFolder.Title = "" Then
Chemin = ""
End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then
Chemin = Mid(objFolder.Title, SecuriteSlash - 1,
2) & ""
End If
ChoixDossierFichier = Chemin
End Function
Starwing
-----Message d'origine-----
bonjour
est ce que qq un pourrait m'aider à résoudre le pb suivant
j'execute la macro suivante
Private Function ChoisirDossier()
Dim objShell, objFolder, chemin, SecuriteSlash As Object
Set objShell = CreateObject("objShell.application")
Set objFolder = _
objShell.BrowseForFolder(&H0&, "Choisisser un
répertoire", &H1&)
On Error Resume Next
chemin = objFolder.ParentFolder.ParseName
(objFolder.Title).Path & ""
If objFolder.Title = "Bureau" Then
chemin = "C:WindowsBureau"
End If
If objFolder.Title = "" Then
chemin = ""
End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then
chemin = Mid(objFolder.Title, SecuriteSlash - 1,
2) & ""
End If
ChoisirDossier = chemin
End Function
mais au moment du débogage j'ai une erreur
"Un composant ActiveX ne peut pas créer l'objet ou
fournir
Sub essai1212() choix = ChoixDossierFichier("d: 9OfficeVBA",1) '<- ici le chemin de ton choix If choix <> "" Then MsgBox choix End Sub
Function ChoixDossierFichier(Racine, Optional SelType As Byte = 0) Dim objShell, objFolder, Chemin, SecuriteSlash, FlagChoix&, Msg$
If SelType = 0 Then FlagChoix = &H1&: Msg = "Choisissez un dossier :" Else FlagChoix = &H4000&: Msg = "Choisissez un fichier :" End If
Set objShell = CreateObject("Shell.Application") 'le troisième paramètre permet de choisir 'la sélection d'un dossier ou d'un fichier (0 ou 1) 'le dernier paramètre permet de choisir le dossier racine Set objFolder = objShell.BrowseForFolder(&H0&, Msg, FlagChoix, Racine) On Error Resume Next Chemin = objFolder.ParentFolder.ParseName (objFolder.Title).path & "" If objFolder.Title = "Bureau" Then Chemin = "C:WindowsBureau" End If If objFolder.Title = "" Then Chemin = "" End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then Chemin = Mid(objFolder.Title, SecuriteSlash - 1, 2) & "" End If ChoixDossierFichier = Chemin End Function
Starwing
-----Message d'origine----- bonjour
est ce que qq un pourrait m'aider à résoudre le pb suivant
j'execute la macro suivante Private Function ChoisirDossier() Dim objShell, objFolder, chemin, SecuriteSlash As Object
Set objShell = CreateObject("objShell.application") Set objFolder = _ objShell.BrowseForFolder(&H0&, "Choisisser un répertoire", &H1&) On Error Resume Next chemin = objFolder.ParentFolder.ParseName (objFolder.Title).Path & "" If objFolder.Title = "Bureau" Then chemin = "C:WindowsBureau" End If If objFolder.Title = "" Then chemin = "" End If
SecuriteSlash = InStr(objFolder.Title, ":")
If SecuriteSlash > 0 Then chemin = Mid(objFolder.Title, SecuriteSlash - 1, 2) & "" End If ChoisirDossier = chemin End Function
mais au moment du débogage j'ai une erreur "Un composant ActiveX ne peut pas créer l'objet ou fournir