Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Application.Calculation gives run time error

Hallo,

In one of my VB subroutines I have included an Application.Calculation =
xlCalculationManual instruction. I normally activate this subroutine by
attaching it as a macro (Assign Macro) to a button which I have added to my
worksheet using the Forms Toolbar. This works without problems.

Now I would like to use the Control Toolbox to put a similar button on my
worksheet (I am using Excel 97). However, to this button I can not directly
assign a macro anymore (at least I don't know how), so I use the
Button_x_Click event to start my subroutine. I have added this code to my VB
sheet:

Private Sub Button_X_Click()
Call Y
End Sub

Subroutine Y is placed in a module sheet within the same workbook

Sub Y
Application.Calculation = xlCalculationManual
.. rest of code
End Sub

When I now click on the button, I get a runtime error 1004 "Method
calculation of object application failed"

Any reaction is appreciated,
Martien


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.Calculation gives run time error

I'm not sure if this will help, but you could try:
xlManual
Both constants represent -4135

(but maybe xlCalculationManual was added with xl97???)


And another guess (your code worked ok for me in xl2003)...

There is a bug in xl97 with controls from the control toolbox toolbar. You can
go into design mode and change the .takefocusonclick to false.

This bug was fixed in xl2k.

If the control doesn't have this property, you can add a line to your code:

activecell.activate

(which will actually work even if the control has a .takefocusonclick property)

This is a common problem when a range is being manipulated--I'm not sure if it
helps with the application.calculation line, though.

Could you post back your results (I'm kind of curious).

Martien Janssen wrote:

Hallo,

In one of my VB subroutines I have included an Application.Calculation =
xlCalculationManual instruction. I normally activate this subroutine by
attaching it as a macro (Assign Macro) to a button which I have added to my
worksheet using the Forms Toolbar. This works without problems.

Now I would like to use the Control Toolbox to put a similar button on my
worksheet (I am using Excel 97). However, to this button I can not directly
assign a macro anymore (at least I don't know how), so I use the
Button_x_Click event to start my subroutine. I have added this code to my VB
sheet:

Private Sub Button_X_Click()
Call Y
End Sub

Subroutine Y is placed in a module sheet within the same workbook

Sub Y
Application.Calculation = xlCalculationManual
.. rest of code
End Sub

When I now click on the button, I get a runtime error 1004 "Method
calculation of object application failed"

Any reaction is appreciated,
Martien


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Application.Calculation gives run time error

Hi Martien,

In Designer mode (top left button on the controls toolbox menu) right click
the button, view properties.
Change the TakeFocusOnClick" property to false (only need to do this in
XL97).

You should now be able to run your macro or move that calculation line into
the Click event.

Macros are not assigned to Worksheet controls from the Controls toolbox
menu. Instead they respond to Events, of which "Click" is just one of many.
Being the most common event for a button that is what automatically gets
written into the sheet module. With the cursor in the click event look at
the dropdown top right of the module.

Regards,
Peter T

"Martien Janssen" wrote in message
. ..
Hallo,

In one of my VB subroutines I have included an Application.Calculation =
xlCalculationManual instruction. I normally activate this subroutine by
attaching it as a macro (Assign Macro) to a button which I have added to

my
worksheet using the Forms Toolbar. This works without problems.

Now I would like to use the Control Toolbox to put a similar button on my
worksheet (I am using Excel 97). However, to this button I can not

directly
assign a macro anymore (at least I don't know how), so I use the
Button_x_Click event to start my subroutine. I have added this code to my

VB
sheet:

Private Sub Button_X_Click()
Call Y
End Sub

Subroutine Y is placed in a module sheet within the same workbook

Sub Y
Application.Calculation = xlCalculationManual
.. rest of code
End Sub

When I now click on the button, I get a runtime error 1004 "Method
calculation of object application failed"

Any reaction is appreciated,
Martien




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Application.Calculation gives run time error

Hi Dave,

I didn't see yours when I sent mine. You asked the OP -

Could you post back your results (I'm kind of curious).


In my XL97 I replicated the OP's error. Changing .takefocusonclick to false
fixed it

Regards,
Peter T


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Application.Calculation gives run time error

Dear Peter and Dave,

Many thanks for your reply. Indeed, setting .takefocusonclick to false did
the job. I would never have found that one myself.

Many thanks again,

Regards,

Martien


"Peter T" <peter_t@discussions wrote in message
...
Hi Dave,

I didn't see yours when I sent mine. You asked the OP -

Could you post back your results (I'm kind of curious).


In my XL97 I replicated the OP's error. Changing .takefocusonclick to
false
fixed it

Regards,
Peter T






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.Calculation gives run time error

Thanks for checking (and posting!).

Peter T wrote:

Hi Dave,

I didn't see yours when I sent mine. You asked the OP -

Could you post back your results (I'm kind of curious).


In my XL97 I replicated the OP's error. Changing .takefocusonclick to false
fixed it

Regards,
Peter T


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.Calculation gives run time error

And thanks for posting back with your results.

Martien Janssen wrote:

Dear Peter and Dave,

Many thanks for your reply. Indeed, setting .takefocusonclick to false did
the job. I would never have found that one myself.

Many thanks again,

Regards,

Martien

"Peter T" <peter_t@discussions wrote in message
...
Hi Dave,

I didn't see yours when I sent mine. You asked the OP -

Could you post back your results (I'm kind of curious).


In my XL97 I replicated the OP's error. Changing .takefocusonclick to
false
fixed it

Regards,
Peter T



--

Dave Peterson
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
I got this problem run-time error 1004 application defined ... Davide Blau Excel Discussion (Misc queries) 2 July 10th 06 09:27 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM
Application Calculation Error Rick B[_4_] Excel Programming 2 December 2nd 03 08:49 PM
Application.Calculation=xlCalculationManual causing run time error? Dave Peterson[_3_] Excel Programming 3 October 18th 03 12:51 AM


All times are GMT +1. The time now is 07:13 AM.

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"