Solved

Dr. Watson with OnTime in Excel VBA Macro

Posted on 2001-08-16
8
941 Views
Last Modified: 2012-06-21
I have constructed the following test set of macros to check out the OnTime method (it moves the cursor after 5 seconds):

Sub GoPauseGo()
    Range("B10").Select
    Application.OnTime Now + TimeValue("00:00:5"), ThisWorkbook.Name & "!GoB4"
End Sub

Sub GoB4()
    Range("B4").Select
End Sub

If I put it in my Personal.xls, it works fine in a test workbook and also in my big workbook -- but if I put it in the workbooks' own modules, it works OK in the test workbook, but gives me a Dr. Watson Exception: access violation (0xc0000005), Address 0x00000000 every time in my big workbook.  What sorts of difference between workbooks could give rise to this behavior?
0
Comment
Question by:EDC
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 17

Accepted Solution

by:
calacuccia earned 150 total points
Comment Utility
Have you tried this, when putting the procedure in the own workbooks' module?

Sub GoPauseGo()
   Range("B10").Select
   Application.OnTime Now + TimeValue("00:00:05"), "!GoB4"
End Sub

Sub GoB4()
   Range("B4").Select
End Sub


0
 
LVL 6

Expert Comment

by:xSinbad
Comment Utility
Using a variable like this

Sub GoPauseGo()
Dim valTime
  Range("B10").Select
  valTime = Now + TimeValue("00:00:05")
  Application.OnTime valTime, "!GoB4"
End Sub
0
 
LVL 17

Expert Comment

by:calacuccia
Comment Utility
Oops, make that

Sub GoPauseGo()
  Range("B10").Select
  Application.OnTime Now + TimeValue("00:00:05"), "GoB4"
End Sub

Sub GoB4()
  Range("B4").Select
End Sub
0
 

Author Comment

by:EDC
Comment Utility
Sorry, Calacuccia and xSinbad -- Those are valid procedures, but they don't work in my strangely behaving workbook.

Using the valTime variable ascertained that Excel is choking on the TimeValue function.

Here's another clue:  MsgBox doesn't work, either -- gives the same Dr. Watson, at address 0x0fb78e03 -- but works OK when run from Personal.xls, or in another workbook's module.  Could I be accessing just a subset of VBA functions somehow?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Expert Comment

by:xSinbad
Comment Utility
How is this going EDC I cannot reproduce your fault, have you tried creating a new workbook and trying in that because this one looks corupt...


8->
Marcus
0
 
LVL 6

Expert Comment

by:xSinbad
Comment Utility
One last idea, if you are putting it in the module have you tried making it a function instead of a sub?
0
 

Author Comment

by:EDC
Comment Utility
Thanks for your efforts, xSinbad and calacuccia -- it seems that I did indeed have a corrupted workbook.  I moved everything over to a fresh file and things are working fine now.

I'm going to attempt to split the points.
0
 

Expert Comment

by:ComTech
Comment Utility
Hi EDC, I have refunded 150 points for a split.  I have accpeted calacuccia's points here.

You nee to create an NEW question in this Topic Area and Entitle it *Points for xsinbad*

In the commmet box type *Points for xsinbad for your split in my question #20169698*

Choose 150 points and click on Submit, that will finish the split (of course, when he comments, just accept the comment and, it will close.

Regards,
ComTech
Community Support Moderator
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
excel forecast function 1 29
Excel Max 6 31
still having troubles with an Excel Macro saving to C: on Windows 10 5 31
Oart.dll 2 24
How many times recently have you prepared a presentation or emailed a document to a client and you have found that they have older versions of MS Office and they can not open the file you have prepared.  Although most visitors to this site are exper…
In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now