View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Cater for unregistered DLL

Normally my VB6 ActiveX DLL should be registered in user's system, and a
reference set to it in my project. However, before running my main routine,
I want to ensure it is indeed registered and avert all the problems of a
missing ref.

I have something like this, which fails -

'Module1
Public mbDllReg As Boolean

Sub Auto_Open()
Dim obDLL As Object

On Error Resume Next

Set obDLL = CreateObject("MyDLL.Some")

If Not obDLL Is Nothing Then
Set obDLL = Nothing
mbDllReg = True
End If

End Sub

Sub StartHere()
If mbDllReg Then
DoMain
Else
MsgBox "DLL not registered"
End If
End Sub

'Module2
Public pDllRef As MyDLL.Some

Sub DoMain()

Set pDdllRef = New MyDLL.Some
' do stuff

End Sub

If I unregister the dll before opening my file, when the wb opens and the
Open routine runs, the code breaks on "pDllRef As MyDLL.Some" at the top of
Module2.

If I only declare the DllRef at procedure level - no problem, but I do need
a public ref to the DLL-class.

FWIW, Module1 is the first module added to the project, and no difference if
project is/not pre-compiled.

Any solution much appreciated,
Peter T