×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Delay the macros with Application.Wait Now + TimeValue("00:00:02")

Delay the macros with Application.Wait Now + TimeValue("00:00:02")

Delay the macros with Application.Wait Now + TimeValue("00:00:02")

(OP)
Hello All, I am trying to delay the macro from running for 2 seconds as per VBA code below. But it does not work and give me an error message at statement:
Application.Wait Now + TimeValue("00:00:02").

I also tried to use a MsgBox and SendKeys "{Enter}" trying to delay the program from runing , True, but it does not work either.
So, what is the right syntax or command to delay the macro for 2 more few seconds?

Remember, it is VBA code, not VB or CATScript. Please help me out.

Thank you

===================================
'Program purpose: To delay running the code 2 seconds before switching the cameras

Sub CAMERA()

Dim my3DViewer
Set my3DViewer = CATIA.ActiveWindow.ActiveViewer

MsgBox CATIA.ActiveDocument.Cameras.Count

CATIA.RefreshDisplay = True
MsgBox "Macro is running..."
' SendKeys "{Enter}", True '''' I tried this function, but it did not work well. So, I put it in comment text

Dim oCamera3D As Camera3D
Dim CameraIdent
For CameraIdent = 1 To CATIA.ActiveDocument.Cameras.Count
Set oCamera3D = CATIA.ActiveDocument.Cameras.Item(CameraIdent)
MsgBox oCamera3D.Name '//// Display camera's name

Dim Application
Set Application = CATIA
Application.Wait Now + TimeValue("00:00:02") ' Error here: "method or property is not supported"

CATIA.StartCommand "Fit All In" ' Testing lines of code above

Next
End Sub
==========================================
Thank you in advance

Quin

RE: Delay the macros with Application.Wait Now + TimeValue("00:00:02")

Hi,

Why delay "2 seconds?"

Usually a Wait is used in some asynchronous situation, where, for instance, a command is issued to some system over which the program has no control, and the program must wait for that other system to complete some process, and the Wait must continue until the program can detect something that is an indication that that process is done.

That's accomplished in a loop, with DoEvents to enable all processes (not just the loop process) and a test of the something that is an indication that the process is done.

That something, is what you need to find. What can indicate to your program that the paste is complete? It can't be "2 seconds!"

CODE

Do Until (something exists)
   DoEvents
Loop 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources