Is it possible tse my VB procedure in Form VBS script ?

B

Bert_Bert

I have DLL addin in VB6 that has already ready function for special filtering
based on text SWL query, e.g.
[Categories]='mycateg' AND [MyFiled]='myvalue' AND [anotheruserfield]>0

Since the txt SQL query is specified onf customized form, I would like to
return number of returned records and I do not want to repeat program - I use
Redemption to perform filtering and in Form VBS it would be too longd and
badly maintained.

Do I have some possibility to
1. check whether my DLL is registered and initialized
2. call somehow my function to find number of records mathing my custom SQL
and show it on my form ?
3. or, if not possible, perhaps some Event that would be invoked by the DLL
addin and pushed the value to the open form?

tahk you
 
K

Ken Slovak - [MVP - Outlook]

If your DLL is an Outlook COM addin you can use the
Application.COMAddIns.Item("myAddin").Connect Boolean property to see if
your addin is there and connected. You could check for registration using
calls to the registry to see if the dll is registered. If an addin you could
also check the LoadBehavior value to see if the addin was set to connect on
startup or on demand.

You can certainly connect to your addin from the outside world (a form) and
call a method in your addin if that method is exposed. For a VB6 addin it's
as simple as setting AddInInst.Object = Me in your OnConnection() handler
and having a public Sub or Function in that connect class. That can then
have the complete code or proxy to a Sub or Function somewhere else in your
addin code.

On the calling side you'd use code like this:

Dim oAddinBase 'as Object
Set oAddinBase = Application.COMAddIns.Item("myAddin").Object

From there you can use the oAddinBase object to call your public Subs or
Functions. For example, you have a Function named Foobar that returns a
Boolean:

Dim blnResult
blnResult = oAddinBase.Foobar()
 
B

Bert_Bert

Wonderful ! I did not hope that it could work so easy.
Just had to google a detail and correct:
Set oAddinBase = Application.COMAddIns.Item("myAddin").Object
Set oAddinBase = Application.COMAddIns.Item("myAddin.Connect").Object

and after while (well, while before computer always means several hours :) )
it works. What I could not understand was why I saw as a name
"Microsoft.VbaAddinForOutlook" and tried to find out how to change ProgID of
my DLL manually and was a bit confused what precisely REGSVR32 does tu put
the object in the registry.

But as far as I did
Set oAddinBase = Application.COMAddIns.Item("myAddin.Connect").Object
I could find the addin according to my name in VBScript.

Thank you for a good tip Ken !


If your DLL is an Outlook COM addin you can use the
Application.COMAddIns.Item("myAddin").Connect Boolean property to see if
your addin is there and connected. You could check for registration using
calls to the registry to see if the dll is registered. If an addin you could
also check the LoadBehavior value to see if the addin was set to connect on
startup or on demand.

You can certainly connect to your addin from the outside world (a form) and
call a method in your addin if that method is exposed. For a VB6 addin it's
as simple as setting AddInInst.Object = Me in your OnConnection() handler
and having a public Sub or Function in that connect class. That can then
have the complete code or proxy to a Sub or Function somewhere else in your
addin code.

On the calling side you'd use code like this:

Dim oAddinBase 'as Object
Set oAddinBase = Application.COMAddIns.Item("myAddin").Object

From there you can use the oAddinBase object to call your public Subs or
Functions. For example, you have a Function named Foobar that returns a
Boolean:

Dim blnResult
blnResult = oAddinBase.Foobar()




Bert_Bert said:
I have DLL addin in VB6 that has already ready function for special
filtering
based on text SWL query, e.g.
[Categories]='mycateg' AND [MyFiled]='myvalue' AND [anotheruserfield]>0

Since the txt SQL query is specified onf customized form, I would like to
return number of returned records and I do not want to repeat program - I
use
Redemption to perform filtering and in Form VBS it would be too longd and
badly maintained.

Do I have some possibility to
1. check whether my DLL is registered and initialized
2. call somehow my function to find number of records mathing my custom
SQL
and show it on my form ?
3. or, if not possible, perhaps some Event that would be invoked by the
DLL
addin and pushed the value to the open form?

tahk you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top