简体   繁体   中英

WinSCP .NET assembly with VBA throwing ActiveX component can't create object

I have recently registered the WinSCPnet.dll using .NET Framework C:\\Windows\\Microsoft.NET\\Framework64\\v2.0.50727 . And I have added the tlb file generated to my VBA references. But when I try to instantiate SessionOptions object, it throws an error "ActiveX component can't create object" . Not sure what went wrong here.

Also, I found that I was able to connect using VBScript. But if I use VBA, it is not working. Can anyone suggest what is the problem?

If your Microsoft Excel installation is 32-bit application, you have to register the WinSCPnet.dll for 32-bit .NET framework, even on a 64-bit system.

As the instructions for registering the WinSCP .NET assembly for COM show, on 64-bit system, you generally need to register the assembly both for 32-bit and 64-bit:

%WINDIR%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe WinSCPnet.dll /codebase /tlb:WinSCPnet32.tlb
%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe WinSCPnet.dll /codebase /tlb:WinSCPnet64.tlb

Do not add the .tbl manually to Excel. The assembly appears itself after being registered correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM