0

I successfully created in VB6 the VB6_IDE_Add_In, that has references to Microsoft "Visual Basic 6.0 Extensibility". However, to use this add-in in VBA IDE (Excel, Access) I obliged to make a copy of VB6_IDE_Add_In project, rename it to VBA_IDE_Add_In, rename its properties etc. and, the main, change mentioned reference to "Microsoft Visual Basic for Applications Extensibility 5.3".

Finally I have two dll - the one for VB6, and the second - for VBA. Both of them I must to "regsvr32" and manually move VBA-IDE-Add-In registry key from VB6 key "[HKCU\Software\Microsoft\Visual Basic\6.0\Addins]" to VBA key [HKCU\Software\Microsoft\VBA\VBE\6.0\Addins]...

Is there a way to compile a single dll that will use right reference accordingly to the VB6 or the VBA environment, using conditional compilation or command line parameter?

Unfortunately, this is my first add-in and my experience is insufficient in this matter...

ThunderFrame
  • 9,352
  • 2
  • 29
  • 60
user6698332
  • 407
  • 3
  • 14
  • @Rory You really acted wisely cutting my tags, leaving very little demanded. To less people saw this complex issue and I did not get an answer at all. Thank you. – user6698332 Aug 16 '16 at 22:53
  • 2
    Your question is about VB6 not VBA, since you can no longer build dlls with VBA. If you have an issue with that, feel free to take it up with the powers that be. – Rory Aug 16 '16 at 22:58
  • 4
    The OP question *is* about VB6 *and* VBA. You can no longer write a dll in VBA, but you *can* write a dll *for* VBA in VB6. – ThunderFrame Aug 22 '16 at 23:56

1 Answers1

3

I doubt you'll be able to compile a single add-in in VB6 for VB6 and VBA, as both libraries share the same name VBIDE and your VB6 project won't allow two references with the same name. MZTools 3.0, when it was written in VB6, used to publish a version for VB5 (which uses yet another, earlier version of VB extensibility library), VB6 and VBA. Since the release of MZ Tools Version 8, the source has been migrated to .NET, and it is much easier to support multiple environments and 32-bit/64-bit versions of VB/VBA hosts.

You would be wise to follow the lead, and develop a solution using .NET. A .NET solution like MZ Tools, or Rubberduck VBA, can be used by 32-bit and 64-bit hosts, and by creating your own Interop Assemblies (and embedding their types) from the VBIDE type libraries, you can create a single dll for VB5, VB6 and VBA.

Rubberduck VBA hasn't yet added support for VB6, but we're working on it:

Shared VB6 and VBA extensibility add-in with OnConnect and OnDisconnect handling

Community
  • 1
  • 1
ThunderFrame
  • 9,352
  • 2
  • 29
  • 60
  • OK. I will stop searching in this direction. My scheme - two dll, identical in code, but with different names and references to Extensibility - is working very well. Thank you very mutch for save me from time waste for searches. – user6698332 Aug 23 '16 at 01:24