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
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")
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Delay the macros with Application.Wait Now + TimeValue("00:00:02")
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
Skip,
Just traded in my OLD subtlety...
for a NUance!