Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Using a dll in vba

I created a dll in vb 5. I am trying to use the dll in a spreadsheet but I am
getting the runtime error 453 "Can't find DLL entry Point" (using excel 2000)

I have the following code in a module:
Declare Sub cleanup Lib "f:\final inspection\master
templates\final_inspection" ()

I have the following code in a button on the sheet:
Sub cmdcleanup_Click()
cleanup
End Sub

The sub cleanup is public in the dll and I have also created referances in
the workbook to the dll.

David


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Using a dll in vba

You cannot create normal Windows DLLs in Visual Basic. You can
create ActiveX DLLs. You can then call them with code like

Dim MyObject As DLLProjectName.MyObjectClass
Set MyObject = New DLLProjectName.MyObjectClass
MyObject.ProcedureName

You'll need to set a reference to the DLLProjectName. In VBA, go
to the Tools menu, choose References, and select your
DLLProjectName from the list.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com







"David" wrote in message
...
I created a dll in vb 5. I am trying to use the dll in a
spreadsheet but I am
getting the runtime error 453 "Can't find DLL entry Point"
(using excel 2000)

I have the following code in a module:
Declare Sub cleanup Lib "f:\final inspection\master
templates\final_inspection" ()

I have the following code in a button on the sheet:
Sub cmdcleanup_Click()
cleanup
End Sub

The sub cleanup is public in the dll and I have also created
referances in
the workbook to the dll.

David




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Using a dll in vba

The reference to an ActiveX DLL is PROJECTNAME.CLASSNAME.

The methods are all public Subs and Functions, and the properties are
Property Let/Get and Variables declared as public.

API declarations and variables declared as Private are NOT exposed.

I am not sure what your CleanUp is going to do but you need to encapsulate
the API in a public SUB (Or Function)

On the machine that created the DLL:

Set MyDLL = CreateObject(project.class) ' substitute as necessary

Sub cmdcleanup_Click()
MyDll.cleanupCF
End Sub

where cleanupCF is the wrapper (Sub or Function) around cleanup.

On other machines, you would need to register the DLL before using it, using
REGSVR32.




"David" wrote:

I created a dll in vb 5. I am trying to use the dll in a spreadsheet but I am
getting the runtime error 453 "Can't find DLL entry Point" (using excel 2000)

I have the following code in a module:
Declare Sub cleanup Lib "f:\final inspection\master
templates\final_inspection" ()

I have the following code in a button on the sheet:
Sub cmdcleanup_Click()
cleanup
End Sub

The sub cleanup is public in the dll and I have also created referances in
the workbook to the dll.

David


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Using a dll in vba

It works...but now I am getting a subscript out of range error. The first
part of the cleanup sub is:

For z = 1 To 10
For x = 16 To 45
If Workbooks(3).Worksheets(2).Range("A" & x).Value = "" Then
Rows(x).Select
Selection.Delete
End If
Next x
Next z

x and z are declared as public and the workbook and worksheet numbers are
correct. None of the other buttons work either. Would it help if I used with
statements?

"Chip Pearson" wrote:

You cannot create normal Windows DLLs in Visual Basic. You can
create ActiveX DLLs. You can then call them with code like

Dim MyObject As DLLProjectName.MyObjectClass
Set MyObject = New DLLProjectName.MyObjectClass
MyObject.ProcedureName

You'll need to set a reference to the DLLProjectName. In VBA, go
to the Tools menu, choose References, and select your
DLLProjectName from the list.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com







"David" wrote in message
...
I created a dll in vb 5. I am trying to use the dll in a
spreadsheet but I am
getting the runtime error 453 "Can't find DLL entry Point"
(using excel 2000)

I have the following code in a module:
Declare Sub cleanup Lib "f:\final inspection\master
templates\final_inspection" ()

I have the following code in a button on the sheet:
Sub cmdcleanup_Click()
cleanup
End Sub

The sub cleanup is public in the dll and I have also created
referances in
the workbook to the dll.

David





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Using a dll in vba

What line of code is giving you the error? Also, when deleting
rows, it is always best to delete from the bottom up, rather than
top down. Otherwise, you'll end up deleting rows you don't want
to or skipping rows.

For x = 16 To 45
to
For x = 45 To 16 Step -1


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"David" wrote in message
...
It works...but now I am getting a subscript out of range error.
The first
part of the cleanup sub is:

For z = 1 To 10
For x = 16 To 45
If Workbooks(3).Worksheets(2).Range("A" & x).Value =
"" Then
Rows(x).Select
Selection.Delete
End If
Next x
Next z

x and z are declared as public and the workbook and worksheet
numbers are
correct. None of the other buttons work either. Would it help
if I used with
statements?

"Chip Pearson" wrote:

You cannot create normal Windows DLLs in Visual Basic. You can
create ActiveX DLLs. You can then call them with code like

Dim MyObject As DLLProjectName.MyObjectClass
Set MyObject = New DLLProjectName.MyObjectClass
MyObject.ProcedureName

You'll need to set a reference to the DLLProjectName. In VBA,
go
to the Tools menu, choose References, and select your
DLLProjectName from the list.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com







"David" wrote in message
...
I created a dll in vb 5. I am trying to use the dll in a
spreadsheet but I am
getting the runtime error 453 "Can't find DLL entry Point"
(using excel 2000)

I have the following code in a module:
Declare Sub cleanup Lib "f:\final inspection\master
templates\final_inspection" ()

I have the following code in a button on the sheet:
Sub cmdcleanup_Click()
cleanup
End Sub

The sub cleanup is public in the dll and I have also created
referances in
the workbook to the dll.

David









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Using a dll in vba

I never done this before. Could you tell me where I could find some source
code so I can figure out how to do this?

David


"NickHK" wrote:

David,
You sub "cleanup" is in the DLL ?
If so, then it has no idea what Workbooks(3) refers to, as it is NOT in
Excel.
At the least, you would have to pass a reference to the DLL of the Excel
instance.
e.g.
'In the DLL
Public sub CleanUp(argWhichExcel As Excel.Application)
With argWhichExcel.Workbooks(3).Worksheets(2).
....etc

But it may be better to create a class (or extra sub arguments) to
explicitly set the Excel instance, WB, WS, range etc, then call .CleanUp.
Otherwise your DLL code is limited to a single fixed task, which kind of
defeats the point of putting it in a separate DLL in the first place.

NickHK


"David" wrote in message
...
It works...but now I am getting a subscript out of range error. The first
part of the cleanup sub is:

For z = 1 To 10
For x = 16 To 45
If Workbooks(3).Worksheets(2).Range("A" & x).Value = "" Then
Rows(x).Select
Selection.Delete
End If
Next x
Next z

x and z are declared as public and the workbook and worksheet numbers are
correct. None of the other buttons work either. Would it help if I used

with
statements?

"Chip Pearson" wrote:

You cannot create normal Windows DLLs in Visual Basic. You can
create ActiveX DLLs. You can then call them with code like

Dim MyObject As DLLProjectName.MyObjectClass
Set MyObject = New DLLProjectName.MyObjectClass
MyObject.ProcedureName

You'll need to set a reference to the DLLProjectName. In VBA, go
to the Tools menu, choose References, and select your
DLLProjectName from the list.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com







"David" wrote in message
...
I created a dll in vb 5. I am trying to use the dll in a
spreadsheet but I am
getting the runtime error 453 "Can't find DLL entry Point"
(using excel 2000)

I have the following code in a module:
Declare Sub cleanup Lib "f:\final inspection\master
templates\final_inspection" ()

I have the following code in a button on the sheet:
Sub cmdcleanup_Click()
cleanup
End Sub

The sub cleanup is public in the dll and I have also created
referances in
the workbook to the dll.

David








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



All times are GMT +1. The time now is 02:05 PM.

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

About Us

"It's about Microsoft Excel"