View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Mangesh Yadav[_4_] Mangesh Yadav[_4_] is offline
external usenet poster
 
Posts: 101
Default Addressing a UserForm sub in a VB dll

Hi DM Unseen

Thanks for the suggestions. Although at the first try, it doesn't seem to be
working in my case (need to try harder, but no time at the moment). Will let
you know about it all the same.

Mangesh




"DM Unseen" wrote in message
oups.com...
The short explanation is: You should not do callback from VB into XL.
i.e. when you have an XL addin that uses an VB DLL, the VB DLL should
not use custom procedures or custom classes inside XL, this is an
important design issue.

This said, it is possible to do this, but with class modules this
becomes very tricky. With Userforms i'm not even surer that this is
possible without the following Hack(use at your own risk)

In the XL addin set the following Macro:

Public Function LoadUserForm(varForm As Variant) As Object

Set LoadUserForm = VBA.UserForms.Add(varForm)
' see this reference is not available outside the XL VBA project!!!! so
no way of opening an Userform from VB directly
End Function

in yout VB Code

Sub Main(myapp as Workbook)
Dim XL as Excel.Application

Set XL = myapp.parent

XL.run (myapp.name &"!LoadUserForm","UserForm1").UFTest
' runs the form with helper function in XL addin.
End SUb


Dm Unseen