Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default xllRegister method

hi. I'm still trying to use xll files to be able to use c++ code for custom
excel functions. No one seems to be fielding these questions, but I thought
I'd try again. I'm trying to use the xllregister method in vba to call
functions in an xll file. here is the code:

sub main()
Application.registerxll "filename.xll"
Dim c As integer
c = AddTwo(8,9)
....
End Sub

I get an error message "sub or function not defined"
The addtwo function from my xll works fine when used in excel. Any
thoughts? I'm pretty much out of my league at this point, but I have to get
this done for work. Pls help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default xllRegister method

Are you saying registerxll fails. AFAIK you only need to register it once so
if your function works in Excel I guess it should work in VBA, though you
need ExecuteExcel4Macro and the right syntax (following might not be right)

c = Application.ExecuteExcel4Macro("AddTwo(" & 8 & "," & 9 & ")")

Regards,
Peter T

"JacksonRJones" wrote in message
...
hi. I'm still trying to use xll files to be able to use c++ code for

custom
excel functions. No one seems to be fielding these questions, but I

thought
I'd try again. I'm trying to use the xllregister method in vba to call
functions in an xll file. here is the code:

sub main()
Application.registerxll "filename.xll"
Dim c As integer
c = AddTwo(8,9)
...
End Sub

I get an error message "sub or function not defined"
The addtwo function from my xll works fine when used in excel. Any
thoughts? I'm pretty much out of my league at this point, but I have to

get
this done for work. Pls help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default xllRegister method

Thanks a million. It worked and now I get to go home on a positive note
after a few days of banging my head against the wall.

"Peter T" wrote:

Are you saying registerxll fails. AFAIK you only need to register it once so
if your function works in Excel I guess it should work in VBA, though you
need ExecuteExcel4Macro and the right syntax (following might not be right)

c = Application.ExecuteExcel4Macro("AddTwo(" & 8 & "," & 9 & ")")

Regards,
Peter T

"JacksonRJones" wrote in message
...
hi. I'm still trying to use xll files to be able to use c++ code for

custom
excel functions. No one seems to be fielding these questions, but I

thought
I'd try again. I'm trying to use the xllregister method in vba to call
functions in an xll file. here is the code:

sub main()
Application.registerxll "filename.xll"
Dim c As integer
c = AddTwo(8,9)
...
End Sub

I get an error message "sub or function not defined"
The addtwo function from my xll works fine when used in excel. Any
thoughts? I'm pretty much out of my league at this point, but I have to

get
this done for work. Pls help.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default xllRegister method

Apparently you can also use the Run method as well (not tested by me):

Syntax 1: Runs a macro or calls a function. This can be used to run a macro
written in Visual Basic or the Microsoft Excel 4.0 macro language, or to run
a function in a DLL or XLL.
Syntax 2: Runs the Microsoft Excel 4.0 macro at this location. The range
must be on a macro sheet.

Syntax 1

expression.Run(Macro, Arg1, Arg2, ...)

Syntax 2

expression.Run(Arg1, Arg2, ...)

expression Optional for Application, required for Range. An expression
that returns the application that contains the macro, or a range on a macro
sheet that contains a Microsoft Excel 4.0 macro.

Macro Required Variant for Syntax 1 (not used with Syntax 2). The macro to
run. This can be either a string with the macro name, a Range object
indicating where the function is, or a register ID for a registered DLL
(XLL) function. If a string is used, the string will be evaluated in the
context of the active sheet.

Arg1, Arg2, ... Optional Variant. The arguments that should be passed to
the function.

Remarks

You cannot use named arguments with this method. Arguments must be passed by
position.

The Run method returns whatever the called macro returns. Objects passed as
arguments to the macro are converted to values (by applying the Value
property to the object). This means that you cannot pass objects to macros
by using the Run method.


Run Method Example

This example shows how to call the function macro My_Func_Sum, which is
defined on the macro sheet Mycustom.xlm (the macro sheet must be open). The
function takes two numeric arguments (1 and 5, in this example).

mySum = Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)
MsgBox "Macro result: " & mySum


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
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM
Please post this thread a complete correct method, method about te Nast Runsome New Users to Excel 0 February 23rd 08 09:42 PM
Another Method or 2? JMay Excel Discussion (Misc queries) 9 February 9th 07 08:11 PM
GetObject method not work after Call Shell Method ben Excel Programming 8 February 21st 06 03:45 PM
Why QUIT method doesn't work after COPY method? surotkin Excel Programming 3 October 26th 05 04:32 PM


All times are GMT +1. The time now is 11:30 AM.

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"