PC Review


Reply
Thread Tools Rate Thread

Create dll file and call it from Excel worksheet or macro

 
 
=?Utf-8?B?RmluZFNvbHV0aW9u?=
Guest
Posts: n/a
 
      7th Jun 2007
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!
 
Reply With Quote
 
 
 
 
merjet
Guest
Posts: n/a
 
      8th Jun 2007
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


 
Reply With Quote
 
=?Utf-8?B?RmluZFNvbHV0aW9u?=
Guest
Posts: n/a
 
      8th Jun 2007
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
>
>
>

 
Reply With Quote
 
=?Utf-8?B?dXJrZWM=?=
Guest
Posts: n/a
 
      8th Jun 2007

"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 With Quote
 
merjet
Guest
Posts: n/a
 
      8th Jun 2007
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a Macro to update File and Worksheet References in Formulas Padrager Microsoft Excel Programming 1 11th Dec 2007 11:44 AM
Call a batch file from an Excel Macro =?Utf-8?B?QWxleCBIb3Jhbg==?= Microsoft Excel Misc 0 2nd Mar 2006 03:29 PM
RE: Call a batch file from an Excel Macro =?Utf-8?B?R2FyeScncyBTdHVkZW50?= Microsoft Excel Misc 0 2nd Mar 2006 03:26 PM
how can i call macro in powerpoint file from excel file pm Microsoft Excel Programming 3 6th Jan 2006 10:40 PM
Create a Worksheet by getting datas from the txt file with Macro =?Utf-8?B?TWFuc29vciBBbGk=?= Microsoft Excel Programming 0 19th Apr 2005 10:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:45 AM.