Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Calling a DLL Trouble

I'm sorry if this appears more than once, I've been having trouble posting
to this group...



Hello all,



I could use some help here...



I have a dll called LindAccessComponent.dll which is registered with Windows
and included as a reference under Tools - References.



I'm copying the code from VB6 to VBA but can't get it to work.



In VB6 FormMain loads and does this in Form_Load()...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess

Set iLeg = iConnect

Set iOrder = iConnect

Set iCheck = iConnect



and in the form's declaration section there is this...

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

Dim iOrder As LIND_ACCESS_COMPONENTLib.iOrder

Dim iLeg As LIND_ACCESS_COMPONENTLib.iLeg

Dim iCheck As LIND_ACCESS_COMPONENTLib.iCheck



and as a result any procedure within the form that uses iConnect, etc. knows
what iConnect is.



In Excel VBA I have done this...

In Sheet2's declaration section I have....

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

Public iOrder As LIND_ACCESS_COMPONENTLib.iOrder

Public iLeg As LIND_ACCESS_COMPONENTLib.iLeg

Public iCheck As LIND_ACCESS_COMPONENTLib.iCheck



In ThisWorkbook I call a sub from Workbook_Open() that does...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess

Set iLeg = iConnect

Set iOrder = iConnect

Set iCheck = iConnect



BUT... whenever I try to use iConnect.anything I get an "Object Required"
error. What am I doing wrong?? If I put Set iConnect = New
LIND_ACCESS_COMPONENTLib.LindAccess in each proceudre it works - but I'm
pretty sure that this is not the right way to do it.



Any direction would be greatly appreciated!



Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Calling a DLL Trouble

Hi Trip,

In Sheet2's declaration section I have....

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess


This creates an automatic custom property of the Sheet2 class called
iConnect.

In ThisWorkbook I call a sub from Workbook_Open() that does...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess


Because iConnect is a property of the Sheet2 class, you need to qualify
it with its parent object name in order to use it from anywhere else, i.e.:

Set Sheet2.iConnect = New......

But unless I'm missing something you haven't described in this post, I'd
recommend against this architecture in general. When you have an object
outside of Excel that you need to wrap in a class module you should use a
VBA class module to do it rather than trying to slip it behind one of
Excel's document object modules. Create a global object variable referencing
that class in a standard code module and then you can use it from anywhere
in your project once its initialized.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Trip" wrote in message
...
I'm sorry if this appears more than once, I've been having trouble posting
to this group...



Hello all,



I could use some help here...



I have a dll called LindAccessComponent.dll which is registered with
Windows and included as a reference under Tools - References.



I'm copying the code from VB6 to VBA but can't get it to work.



In VB6 FormMain loads and does this in Form_Load()...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess

Set iLeg = iConnect

Set iOrder = iConnect

Set iCheck = iConnect



and in the form's declaration section there is this...

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

Dim iOrder As LIND_ACCESS_COMPONENTLib.iOrder

Dim iLeg As LIND_ACCESS_COMPONENTLib.iLeg

Dim iCheck As LIND_ACCESS_COMPONENTLib.iCheck



and as a result any procedure within the form that uses iConnect, etc.
knows what iConnect is.



In Excel VBA I have done this...

In Sheet2's declaration section I have....

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

Public iOrder As LIND_ACCESS_COMPONENTLib.iOrder

Public iLeg As LIND_ACCESS_COMPONENTLib.iLeg

Public iCheck As LIND_ACCESS_COMPONENTLib.iCheck



In ThisWorkbook I call a sub from Workbook_Open() that does...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess

Set iLeg = iConnect

Set iOrder = iConnect

Set iCheck = iConnect



BUT... whenever I try to use iConnect.anything I get an "Object Required"
error. What am I doing wrong?? If I put Set iConnect = New
LIND_ACCESS_COMPONENTLib.LindAccess in each proceudre it works - but I'm
pretty sure that this is not the right way to do it.



Any direction would be greatly appreciated!



Thanks!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Calling a DLL Trouble

Thanks Rob,

It took some trial and error but I just got it running. Thanks for the
pointers!

Trip

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Calling a DLL Trouble

Thanks so much Rob! I trully appreciate your help.

I took your advice and set it up via a class file. It took a little
finageling but I got it to work - for the most part. The only problem now
is that I'm not getting the events of the DLL to fire. I was hoping you may
be able to point me in the right direction... Here's what I have done:

In a class file called RefcoExpressInterface I have:
Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

In a module called PublicMethods I have:
Public RE As RefcoExpressInterface
Public iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

Public iOrder As LIND_ACCESS_COMPONENTLib.iOrder
Public iLeg As LIND_ACCESS_COMPONENTLib.iLeg
Public iCheck As LIND_ACCESS_COMPONENTLib.iCheck
Public iStatus As LIND_ACCESS_COMPONENTLib.iStatus
etc...

In another module called RefcoExpress I have:
Sub InitializeRefcoExpress()
Set RE = New RefcoExpressInterface
Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess
Set iLeg = iConnect
Set iOrder = iConnect
Set iCheck = iConnect
Set iStatus = iConnect

iConnect.connect
etc...
End Sub

Public Sub IConnect_Connected()
' ****** THIS WILL NOT FIRE ******* :-(
ThisWorkbook.Worksheets("Home").ConnectionStatus = "Connected"
ThisWorkbook.Worksheets("Home").REDisconnectReason = ""
StartHeartBeatTimer

End Sub

Based on the log files written to by the DLL I am successfully connecting to
the external server but the iConnect_Connected() event won't fire.

Any ideas you may have (or anyone out there) would be greatly appreciated.

Thanks again!!

Trip

"Rob Bovey" wrote in message
...
Hi Trip,

In Sheet2's declaration section I have....

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess


This creates an automatic custom property of the Sheet2 class called
iConnect.

In ThisWorkbook I call a sub from Workbook_Open() that does...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess


Because iConnect is a property of the Sheet2 class, you need to qualify
it with its parent object name in order to use it from anywhere else,
i.e.:

Set Sheet2.iConnect = New......

But unless I'm missing something you haven't described in this post,
I'd recommend against this architecture in general. When you have an
object outside of Excel that you need to wrap in a class module you should
use a VBA class module to do it rather than trying to slip it behind one
of Excel's document object modules. Create a global object variable
referencing that class in a standard code module and then you can use it
from anywhere in your project once its initialized.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm

"Trip" wrote in message
...
I'm sorry if this appears more than once, I've been having trouble
posting to this group...



Hello all,



I could use some help here...



I have a dll called LindAccessComponent.dll which is registered with
Windows and included as a reference under Tools - References.



I'm copying the code from VB6 to VBA but can't get it to work.



In VB6 FormMain loads and does this in Form_Load()...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess

Set iLeg = iConnect

Set iOrder = iConnect

Set iCheck = iConnect



and in the form's declaration section there is this...

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

Dim iOrder As LIND_ACCESS_COMPONENTLib.iOrder

Dim iLeg As LIND_ACCESS_COMPONENTLib.iLeg

Dim iCheck As LIND_ACCESS_COMPONENTLib.iCheck



and as a result any procedure within the form that uses iConnect, etc.
knows what iConnect is.



In Excel VBA I have done this...

In Sheet2's declaration section I have....

Public WithEvents iConnect As LIND_ACCESS_COMPONENTLib.LindAccess

Public iOrder As LIND_ACCESS_COMPONENTLib.iOrder

Public iLeg As LIND_ACCESS_COMPONENTLib.iLeg

Public iCheck As LIND_ACCESS_COMPONENTLib.iCheck



In ThisWorkbook I call a sub from Workbook_Open() that does...

Set iConnect = New LIND_ACCESS_COMPONENTLib.LindAccess

Set iLeg = iConnect

Set iOrder = iConnect

Set iCheck = iConnect



BUT... whenever I try to use iConnect.anything I get an "Object Required"
error. What am I doing wrong?? If I put Set iConnect = New
LIND_ACCESS_COMPONENTLib.LindAccess in each proceudre it works - but I'm
pretty sure that this is not the right way to do it.



Any direction would be greatly appreciated!



Thanks!






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble calling Add-In Macros [email protected] Excel Programming 2 October 15th 05 11:14 AM
Trouble with Calling a workbook Rbp9ad[_2_] Excel Programming 5 October 8th 05 07:58 AM
Calling an Add-In BillCPA Excel Discussion (Misc queries) 2 August 11th 05 09:32 PM
Trouble calling macro James W.[_2_] Excel Programming 1 May 5th 05 07:07 PM
Calling SUB Peter Longstaff Excel Programming 2 February 23rd 04 08:04 PM


All times are GMT +1. The time now is 07:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"