Bonjour,
j'ai écrit une macro (en récupérant des bouts par ci par là) afin de faire un export en batch. Cependant, la macro appelle shell32.dll (pour la sélection des dossiers). Sur mon ordinateur, pas de problème avec "Shell et Automation" activés, mais pour mon collègue, cela affiche une erreur sur cette ligne: "Set SH = New Shell32.Shell".
Erreur: la classe ne gère pas automation ou l'interface attendue.
Je suis sur W7, lui sur W10, les 2 en 64bit. Quelqu'un aurait-il été confronté au même problème ?
Merci d'avance,
Est ce que tu peux faire voir ton code.
le bout de code qui plante:
Function BrowseFolder(Optional Caption As String, _
Optional InitialFolder As String) As String
Dim SH As Shell32.Shell
Dim F As Shell32.Folder
Set SH = New Shell32.Shell
Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)
If Not F Is Nothing Then
BrowseFolder = F.Items.Item.Path
End If
End Function
si j'ai bien compris, j'ai juste à rajouter 2 lignes:
Dim obj as object
Set Obj = CreateObject("Shell.Application")
pour faire ceci ?
Function BrowseFolder(Optional Caption As String, _
Optional InitialFolder As String) As String
Dim SH As Shell32.Shell
Dim F As Shell32.Folder
Dim ShellApp As Object
Set ShellApp = CreateObject("Shell.Application")
Set SH = New Shell32.Shell
Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)
If Not F Is Nothing Then
BrowseFolder = F.Items.Item.Path
End If
End Function
Ben non, là c'est comme si tu n'avais rien fait. Tu déclare un objet ShellApp comme étant un nouvel objet Shell.Application mais tu continues à utiliser ton objet SH.
Dim Folder As Object
Dim F As Folder
Dim ShellApp As Object
Set ShellApp = CreateObject("Shell.Application")
Set F = ShellApp.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS, InitialFolder)
If Not F Is Nothing Then
BrowseFolder = F.Items.Item.Path
End If
Cordialement,
1 « J'aime »
Ah, après modification, la macro plante solidworks maintenant. une idée ?
au temps pour moi, problème résolu, merci