SW2016 Macro op W7 en W10

Hallo

Ik heb een macro geschreven (hier en daar bits ophalen) om een batch-export te doen. De macro roept echter shell32.dll aan (voor mapselectie). Op mijn computer is er geen probleem met "Shell en automatisering" ingeschakeld, maar voor mijn collega toont het een fout op deze regel: "Set SH = New Shell32.Shell". 

 

Fout: De klasse biedt geen ondersteuning voor automatisering of de verwachte interface.

Ik ben op W7, hij op W10, beide in 64bit. Heeft iemand met hetzelfde probleem te maken gehad?

Bij voorbaat dank,

 

Kunt u uw code laten zien.

Hallo

Kijk deze kant op: HIER

Vriendelijke groeten

1 like

Het codefragment dat crasht:

Functie BrowseFolder (optioneel bijschrift als tekenreeks, _
    Optionele InitialFolder als tekenreeks) als tekenreeks

Dim SH als Shell32.Shell
Dim F As Shell32.Map
Stel SH in = Nieuwe Shell32.Shell
Stel F = SH in. BrowseForFolder(0&, Bijschrift, BIF_RETURNONLYFSDIRS, InitialFolder)
Zo niet, dan is F niets, dan is
    BrowseFolder = F.Items.Item.Path
Einde als

Functie beëindigen

 

 

Als ik het goed begrepen heb, hoef ik alleen maar 2 regels toe te voegen:

Dim obj als object

Set Obj = CreateObject("Shell.Application")

 

 om dit te doen?

 

Functie BrowseFolder (optioneel bijschrift als tekenreeks, _
    Optionele InitialFolder als tekenreeks) als tekenreeks

Dim SH als Shell32.Shell
Dim F As Shell32.Map
Dim ShellApp als object
Set ShellApp = CreateObject("Shell.Application")
Stel SH in = Nieuwe Shell32.Shell
Stel F = SH in. BrowseForFolder(0&, Bijschrift, BIF_RETURNONLYFSDIRS, InitialFolder)
Zo niet, dan is F niets, dan is
    BrowseFolder = F.Items.Item.Path
Einde als

Functie beëindigen

Nou nee, het is alsof je niets hebt gedaan. U declareert een ShellApp-object als een nieuw Shell.Application-object, maar u blijft uw SH-object gebruiken.

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

 

Vriendelijke groeten

1 like

Ah, na wijziging crasht de macro nu solidworks. Enig idee?

Op tijd voor mij, probleem opgelost, bedankt