PC Review


Reply
Thread Tools Rate Thread

Calling an XLL from VB?

 
 
=?Utf-8?B?TWF1cnkgTWFya293aXR6?=
Guest
Posts: n/a
 
      17th Oct 2006
I have an ancient XLL plugin for XL that we use, and since the time we
purchased it we've moved most of our code to VB. I'd like to move this over
as well, but I'm not sure how to do it. Is there some way to load an XLL into
VB? And if so, how do we call it? The XLL is currently called use
"Application.Run", but I'm not entirely sure what this command does.

Maury
 
Reply With Quote
 
 
 
 
Franck
Guest
Posts: n/a
 
      17th Oct 2006
Wish this will help you
http://www.planatechsolutions.com/xlpfaq/Q0032.htm


Maury Markowitz a écrit :

> I have an ancient XLL plugin for XL that we use, and since the time we
> purchased it we've moved most of our code to VB. I'd like to move this over
> as well, but I'm not sure how to do it. Is there some way to load an XLL into
> VB? And if so, how do we call it? The XLL is currently called use
> "Application.Run", but I'm not entirely sure what this command does.
>
> Maury


 
Reply With Quote
 
=?Utf-8?B?TWF1cnkgTWFya293aXR6?=
Guest
Posts: n/a
 
      17th Oct 2006
"Franck" wrote:

> Wish this will help you
> http://www.planatechsolutions.com/xlpfaq/Q0032.htm


Well it's not EXACTLY what I need, but it will likely help me get there.
Thanks!

Maury
 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      18th Oct 2006
An XLL is a special form of Dynamic Link Library (DLL). It is compiled from
C or C++ source code probably. So you would not have any way to view the
code in VB.

You would basically have to figure out what the functionality is, develop an
algorithmic approach to achieve that functionality, then program it from
scratch in VB.

Application.Run does just what you say, it causes the xll's code to execute.

--
Regards,
Tom Ogilvy

"Maury Markowitz" <(E-Mail Removed)> wrote in
message news:154AA5C6-7C55-4A62-858A-(E-Mail Removed)...
> "Franck" wrote:
>
>> Wish this will help you
>> http://www.planatechsolutions.com/xlpfaq/Q0032.htm

>
> Well it's not EXACTLY what I need, but it will likely help me get there.
> Thanks!
>
> Maury



 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      18th Oct 2006
Maury,
As Tom says, an XLL is compiled, so forget about seeing the code.
I'm not sure how different an XLL is from a standard DLL, but with the only
XLL that I have on my system (ANALYS32.xll), calls to it seem routed through
XLCALL32.DLL's "Excel4V" function. So, assuming the actual call, arguments
and return type etc are correct (which I am not), this will not work:
Private Declare Function XLLFunc1 Lib "C:\ANALYS32.XLL" Alias "bin2dec"
(BinStr As String) As Long

There probably are ways of using the XLL directly, but not sure how straight
forward in VB:
http://www.delphi3000.com/articles/article_4104.asp?SK=

However, it does seem a rewrite would be easier if you understand the
concepts of the functions in the XLL and create an ActiveX DLL that's native
to VB or a standard DLL with some extra work.

NickHK

"Maury Markowitz" <(E-Mail Removed)> wrote in
message news:154AA5C6-7C55-4A62-858A-(E-Mail Removed)...
> "Franck" wrote:
>
> > Wish this will help you
> > http://www.planatechsolutions.com/xlpfaq/Q0032.htm

>
> Well it's not EXACTLY what I need, but it will likely help me get there.
> Thanks!
>
> Maury



 
Reply With Quote
 
=?Utf-8?B?TWF1cnkgTWFya293aXR6?=
Guest
Posts: n/a
 
      18th Oct 2006
"Tom Ogilvy" wrote:

> An XLL is a special form of Dynamic Link Library (DLL). It is compiled from
> C or C++ source code probably. So you would not have any way to view the
> code in VB.


I don't care about seeing the code. The code I'm talking about moving is OUR
code, which was in Excel and is now in Access. The XLL is a black box, and
that's fine.

> You would basically have to figure out what the functionality is, develop an
> algorithmic approach to achieve that functionality, then program it from
> scratch in VB.


DLL's are generally easy to call from VBA, as long as you know the method
sig. I do in this case. I need to know how to do that into an XLL.

> Application.Run does just what you say, it causes the xll's code to execute.


But how? Exactly what does "Application.Run" mean? Does it call the DLL
loader? Does it hop into a known starting point? What _exactly_ does it do? I
can call Application.Run on methods in other VBA programs, so it's not simply
trivially simple.

Maury
 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      19th Oct 2006
You would call the XLL same as you would a DLL by putting in a declaration.

For application.run to work, I believe you have to use the register function
to register it.


As to run, you look at the vba help on the run command in Excel VBA. Also
several alternative including that are discussed here:

http://tinyurl.com/yfyrpr

At Laurent Longre's site
http://xcell05.free.fr/
select the english page and at the bottom are links to information on XLL's

--
Regards,
Tom Ogilvy


"Maury Markowitz" <(E-Mail Removed)> wrote in
message news:BB6F14D7-D04B-48B5-AD09-(E-Mail Removed)...
> "Tom Ogilvy" wrote:
>
>> An XLL is a special form of Dynamic Link Library (DLL). It is compiled
>> from
>> C or C++ source code probably. So you would not have any way to view the
>> code in VB.

>
> I don't care about seeing the code. The code I'm talking about moving is
> OUR
> code, which was in Excel and is now in Access. The XLL is a black box, and
> that's fine.
>
>> You would basically have to figure out what the functionality is, develop
>> an
>> algorithmic approach to achieve that functionality, then program it from
>> scratch in VB.

>
> DLL's are generally easy to call from VBA, as long as you know the method
> sig. I do in this case. I need to know how to do that into an XLL.
>
>> Application.Run does just what you say, it causes the xll's code to
>> execute.

>
> But how? Exactly what does "Application.Run" mean? Does it call the DLL
> loader? Does it hop into a known starting point? What _exactly_ does it
> do? I
> can call Application.Run on methods in other VBA programs, so it's not
> simply
> trivially simple.
>
> Maury



 
Reply With Quote
 
=?Utf-8?B?TWF1cnkgTWFya293aXR6?=
Guest
Posts: n/a
 
      19th Oct 2006
"Tom Ogilvy" wrote:

> You would call the XLL same as you would a DLL by putting in a declaration.


I think this is the key. Using the Lib declare seems to work, as if the XLL
is nothing more than a DLL -- which I think is exactly the case, a DLL with
some "known extras" inside that Excel looks for. VB appears to be able to use
it without caring about these extras.

Ok, seeing as this is my first attempt at writing a wrapper from scratch,
would you mind a bit of help mapping the data types in the method sig? This
is the entry in the .h, names have been changed to protect the innocent. As
you can see, the API is basically a bunch of "FPSAFEARRAY", which I assume
stands for "floating point safe array".

__declspec(dllimport) double THING(
FPSAFEARRAY FAR* returnedStuff,
FPSAFEARRAY FAR* oneInput, FPSAFEARRAY FAR* anotherInput...,
LPSTR commands,
LPSTR errors);

My questions are fairly basic... most of the inputs are these arrays marked
"FAR*". Do I wrap these as ByRef? And is the array itself mapped onto a
Variant, or is there something more specific I should use? The LPSTR map onto
ByVal String? Errors is an output, so I think I'm actually wrong on that.

Maury

 
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
Calling SQL from code has different behaviour than calling it from MS SQL Server Management Studio jeeji Microsoft C# .NET 1 29th Jun 2006 10:43 AM
Calling DoCmd.RunCommand acCmdSaveRecord, after calling an API function Savvoulidis Iordanis Microsoft Access Form Coding 2 19th Mar 2005 06:34 PM
Fail to send fax when making international fax calling / calling c =?Utf-8?B?c2Ftd2lzZQ==?= Windows XP Help 1 28th Dec 2004 02:31 PM
Calling FormsAuthentication.SignOut() after calling Response.Flush =?Utf-8?B?TWFydGluIExlZQ==?= Microsoft ASP .NET 1 28th Sep 2004 01:47 PM
Server Side button calling page_load before calling it's own click event. Ryan Ternier Microsoft ASP .NET 4 29th Jul 2004 02:06 PM


Features
 

Advertising
 

Newsgroups
 


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