Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Application.Evaluate question

It seems like Application.Evaluate always evaluates the command twice.
I have a custom addin and want to write a macro to evaluate an addin
command. By setting a break point at my addin function, I can see that when
Application.Evaluate is evoked, it called the addin function twice. Is there
any way to disable this behaviour or is there any alternative to
application.evaluate that would only run the command once?

I am using excel 2002 SP3.

Thanks.

(PS. I cannot put the command in a cell and calculate because the
addin-function returns a variable-size array and I want to get the returned
array and do some additional processing on it.)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Application.Evaluate question

Why not just set the array equal to the return of the function? You may need
to set a reference to the project, but this should work:

Sub TestArrayReturn()
Dim myArr As Variant
Dim i As Integer
myArr = TestFunction
For i = LBound(myArr) To UBound(myArr)
MsgBox myArr(i)
Next i
End Sub

Function TestFunction() As Variant
TestFunction = Array(1, 2, 3)
End Function


HTH,
Bernie
MS Excel MVP


"lcsma" wrote in message
...
It seems like Application.Evaluate always evaluates the command twice.
I have a custom addin and want to write a macro to evaluate an addin
command. By setting a break point at my addin function, I can see that
when
Application.Evaluate is evoked, it called the addin function twice. Is
there
any way to disable this behaviour or is there any alternative to
application.evaluate that would only run the command once?

I am using excel 2002 SP3.

Thanks.

(PS. I cannot put the command in a cell and calculate because the
addin-function returns a variable-size array and I want to get the
returned
array and do some additional processing on it.)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Application.Evaluate question

Thanks. I will try this approach. I had difficulty setting reference to the
add-in as it didn't show up in the Tools-References list, but I guess that's
a separate problem.

Out of curiosity, Is this behavior a well known feature of
Application.Evaluate? What's the reason that it needs to evaluate twice?

TIA

"Bernie Deitrick" wrote:

Why not just set the array equal to the return of the function? You may need
to set a reference to the project, but this should work:

Sub TestArrayReturn()
Dim myArr As Variant
Dim i As Integer
myArr = TestFunction
For i = LBound(myArr) To UBound(myArr)
MsgBox myArr(i)
Next i
End Sub

Function TestFunction() As Variant
TestFunction = Array(1, 2, 3)
End Function


HTH,
Bernie
MS Excel MVP


"lcsma" wrote in message
...
It seems like Application.Evaluate always evaluates the command twice.
I have a custom addin and want to write a macro to evaluate an addin
command. By setting a break point at my addin function, I can see that
when
Application.Evaluate is evoked, it called the addin function twice. Is
there
any way to disable this behaviour or is there any alternative to
application.evaluate that would only run the command once?

I am using excel 2002 SP3.

Thanks.

(PS. I cannot put the command in a cell and calculate because the
addin-function returns a variable-size array and I want to get the
returned
array and do some additional processing on it.)




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
evaluate function only in Excel application x taol Excel Programming 1 March 17th 08 09:53 PM
Interpretation of Application.Caller.Parent.Evaluate FARAZ QURESHI Excel Discussion (Misc queries) 1 December 29th 07 07:59 PM
Alternatives to Application.evaluate(Long Formula) Awill Excel Programming 2 April 3rd 07 02:48 AM
Error 2015 with Application.Evaluate Jeff Excel Programming 3 June 6th 06 04:00 PM
A simple question -- Evaluate() kaon[_12_] Excel Programming 2 July 13th 04 10:28 AM


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