Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Calling EXE After Calculation Complete

Hi all

I'm adding a new row with complicate formula, then I calculate that row only
and use "Shell" to call a EXE program to read a worksheet

However, when EXE read the worksheet, the value is still #VALUE or #NAME,
which means the calculation has not yet completed.

Is there any function I can use to wait until the excel calculation complete?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Calling EXE After Calculation Complete

Hi Shawn

Thanks for your reply.

I've tried calling application.calculate then save the workbook before
calling the shell command, but it doesn't work.

I cannot find Application.CalculationState property, is it a new
property come with a newer version of Excel, I'm using Excel 2000 and
this program will be run using Excel 97 as well.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Calling EXE After Calculation Complete

" wrote:
I cannot find Application.CalculationState property, is it a new
property come with a newer version of Excel, I'm using Excel 2000 and
this program will be run using Excel 97 as well.


Hmm. I guess CalculationState is a new property. Sorry about that.

Here's another thing to try. It isn't pretty...

Create a worksheet-module-level flag variable that indicates whether the
calculation is done. Before your code does whatever it does that triggers
the recalculation, set the flag to False.

In the Worksheet's Calculate event, which (I believe) fires *after* the
calculations are done, set that variable to True.

In your code, loop until that flag variable is True. Then call the shell
command.

That, too, may not work, since Excel is supposedly doing everything in one
thread, and the calculation should be done before the VBA code ever gets to
the loop.

You may have to add some idle time in your EXE. Your EXE is definitely
running in a different thread than Excel, and resting that thread may allow
Excel enough time to get itself all updated. (I'm curious how you're getting
the data out of Excel into the EXE. Other folks doing what you're doing
should know about the difficulty.)

Worst comes to worst, write whatever data the EXE needs to a temp file, then
call the EXE on the temp file.

I wish I knew exactly what was going on here. Let us know if you ever find
out.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Calling EXE After Calculation Complete

Thanks Shawn, I added a loop in my EXE to check the vartype is vberror
or not.
After the calculation complete, the values are shown and no more #NAME,
#VALUE
so the EXE can run smoothly.

I have tested that in the loop was added in the VBA module (A) before
calling the EXE, it loops forever as the calculation was triggerring
another VBA module (B). The module A will not release its control for
module B to calculate, so it loops forever.

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
advise calculation is complete Ross in Oz[_2_] Excel Discussion (Misc queries) 5 July 14th 09 06:39 AM
Message telling calculation is complete deeds Excel Discussion (Misc queries) 16 May 5th 08 03:28 PM
Percent Complete? bassec Excel Discussion (Misc queries) 3 March 28th 06 03:31 AM
forcing complete calculation Claude Excel Programming 6 October 21st 03 07:17 PM
range.calculation with UDF not working when calculation is set to automatic Brian Murphy Excel Programming 5 October 14th 03 07:02 PM


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