Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
gearoi
 
Posts: n/a
Default Calling a bit of code from a sheet errors


I have this bit of code which messes up every now and then, but not all
the time at all - I'll try anything to make it work!!! :)

Application.Run "WorkInProgress.xls!Sheet7.CommandButton1_Clic k"

(Have also tried
Sheet7.commandButton1_Click
and
call xxx with both of the above)

And it works MOST of the time - ie it tends to run about 6 of the 200
of these things that I'm doing then it stops. Then it falls over with:

"Method "Run" of object "Application" error (or similar).

Basically it crashes and stops....

But I need it to run through hundreds of times. This is a clear VBA
shortcoming and I was wondering if anyone has a workaround?

Thanks in advance,
Graham.

PS using Excel 2000


--
gearoi
------------------------------------------------------------------------
gearoi's Profile: http://www.excelforum.com/member.php...o&userid=26576
View this thread: http://www.excelforum.com/showthread...hreadid=436808

  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

You're running this code from a different workbook?


I have no idea. But if you move the code to a general module and call that
procedure, does it work more consistently?

(You'd have to call that procedure from the _click event, too if you didn't want
to duplicate the code.)



gearoi wrote:

I have this bit of code which messes up every now and then, but not all
the time at all - I'll try anything to make it work!!! :)

Application.Run "WorkInProgress.xls!Sheet7.CommandButton1_Clic k"

(Have also tried
Sheet7.commandButton1_Click
and
call xxx with both of the above)

And it works MOST of the time - ie it tends to run about 6 of the 200
of these things that I'm doing then it stops. Then it falls over with:

"Method "Run" of object "Application" error (or similar).

Basically it crashes and stops....

But I need it to run through hundreds of times. This is a clear VBA
shortcoming and I was wondering if anyone has a workaround?

Thanks in advance,
Graham.

PS using Excel 2000

--
gearoi
------------------------------------------------------------------------
gearoi's Profile: http://www.excelforum.com/member.php...o&userid=26576
View this thread: http://www.excelforum.com/showthread...hreadid=436808


--

Dave Peterson
  #3   Report Post  
George Nicholson
 
Posts: n/a
Default

Try inserting a "Do Events" line before Application.Run.

If it runs 6 times and then dies, the computer may simply need a second to
catch up with executing code. Worth a try.

HTH,
--
George Nicholson

Remove 'Junk' from return address.


"gearoi" wrote in
message ...

I have this bit of code which messes up every now and then, but not all
the time at all - I'll try anything to make it work!!! :)

Application.Run "WorkInProgress.xls!Sheet7.CommandButton1_Clic k"

(Have also tried
Sheet7.commandButton1_Click
and
call xxx with both of the above)

And it works MOST of the time - ie it tends to run about 6 of the 200
of these things that I'm doing then it stops. Then it falls over with:

"Method "Run" of object "Application" error (or similar).

Basically it crashes and stops....

But I need it to run through hundreds of times. This is a clear VBA
shortcoming and I was wondering if anyone has a workaround?

Thanks in advance,
Graham.

PS using Excel 2000


--
gearoi
------------------------------------------------------------------------
gearoi's Profile:
http://www.excelforum.com/member.php...o&userid=26576
View this thread: http://www.excelforum.com/showthread...hreadid=436808



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
Data Range Mess Karen Charts and Charting in Excel 18 January 14th 06 02:34 PM
Change case...help please Terry Excel Worksheet Functions 14 October 2nd 05 12:29 PM
relative sheet references ala sheet(-1)!B11 so I can copy a sheet. RonMc5 Excel Discussion (Misc queries) 9 February 3rd 05 12:51 AM
how can i select all the cells with same color on a sheet if there are multipale colors by vba code uobt Charts and Charting in Excel 1 December 15th 04 05:27 PM
Function to automatically insert a new sheet as a result of data entry? Mark Mulik Excel Worksheet Functions 2 November 28th 04 02:21 AM


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