Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Create dll file and call it from Excel worksheet or macro

Could some one provide a step-by-step instruction on:

(1) Create a public function, such as

Public Function Addition(double A, double B) As Double
Addition=A+B
End Function

Public Function Subtraction(double A, double B) As Double
Subtraction=A-B
End Function


(2) compile it to a Addition.dll or to a *.dll file which contains both
Addition and Subtraction?

so that (3) in an Excel worksheet, we just use
=Addition(C1, C2)
To carry on a calculation?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Create dll file and call it from Excel worksheet or macro

With a slight change, you can put the functions in a regular module in
Excel's VB Editor and use it. The change is "A as Double" rather than
"double A". A dll can't be made in Excel; VB, VB.NET, C++, etc. is
needed.

Hth,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Create dll file and call it from Excel worksheet or macro

Thanks, Merjet.

But my need is to use dll instead using macro in order to hide the code. I
have vb.net and can compile dll file for ASP use. For example, I only need
specify the name space and add lot of #include system statement, put the dll
file in the same folder or server, then the ASP can pick up all functions.

For Excel, what are the procedures should I follow, and the objective is to
use the use defined function just like the Excel buid-in functions such as
=sum(C1:C10), =Median(C1:C10), etc.

In the Macro VB, I can also directly call the dunction, like A=exp(10), etc.

Thanks for your response.

FindSolution

"merjet" wrote:

With a slight change, you can put the functions in a regular module in
Excel's VB Editor and use it. The change is "A as Double" rather than
"double A". A dll can't be made in Excel; VB, VB.NET, C++, etc. is
needed.

Hth,
Merjet



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Create dll file and call it from Excel worksheet or macro

I haven't used vb.net. I've used VB6 to make a DLL, and guess it's
similar. So I will answer from that background. A DLL has one or more
Public objects of which a calling application can make an instance of.
The Public object will have properties and/or methods that can be
used.

For example, here are some lines of code from a project.
Public moCntrl As Calm.Cntrl
Set myCntrl = New Calm.Cntrl

Calm is a DLL. Cntrl is a Public class which has several Public
objects and methods.

To use the DLL In Excel, it will need a reference in the VB Editor
using the menu Tools | References.

Hth,
Merjet


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Create dll file and call it from Excel worksheet or macro


"FindSolution" wrote:

Could some one provide a step-by-step instruction on:

(1) Create a public function, such as

Public Function Addition(double A, double B) As Double
Addition=A+B
End Function

Public Function Subtraction(double A, double B) As Double
Subtraction=A-B
End Function


(2) compile it to a Addition.dll or to a *.dll file which contains both
Addition and Subtraction?

so that (3) in an Excel worksheet, we just use
=Addition(C1, C2)
To carry on a calculation?

Thanks!


If you don't mind using C#:

http://www.codeproject.com/dotnet/excelnetauto.asp

--
urkec



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
Call a batch file from an Excel Macro Alex Horan Excel Discussion (Misc queries) 0 March 2nd 06 03:29 PM
Call a batch file from an Excel Macro Gary''s Student Excel Discussion (Misc queries) 0 March 2nd 06 03:26 PM
how can i call macro in powerpoint file from excel file pm[_2_] Excel Programming 3 January 6th 06 10:40 PM
Create a Worksheet by getting datas from the txt file with Macro Mansoor Ali Excel Programming 0 April 19th 05 10:01 AM
Button fails to call macro when open an Excel file from web Sam Excel Programming 1 June 30th 04 10:42 PM


All times are GMT +1. The time now is 07:25 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"