Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys does not work on {ENTER} first action

Status
Not open for further replies.

Thosnow

Aerospace
Feb 23, 2017
68
CA
Hi All...I created a simple VBA code to demonstrate the SendKeys command. However, when the very first camera name appears, the SendKeys {"ENTER"} command does not work. I have to manually press Enter key on the keyboard in order to have the loop to continue. SendKeys {"ENTER"} does work on 2nd camera display and after.

So, how could I make the first SendKeys {"ENTER"} command work?

-------------------------

Sub CAMERA()

'//// Display total number of cameras in active document
MsgBox CATIA.ActiveDocument.Cameras.Count

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
CATIA.RefreshDisplay = True
SendKeys "{ENTER}"
Next

CATIA.StartCommand "Fit All In"

End Sub
---------------------
Your help is much appreciated.
 
Replies continue below

Recommended for you

does it work if you start your script with a shortcut instead of any other way?

I am looking for a solution on this problem...

Eric N.
indocti discant et ament meminisse periti
 
what do you mean by " short-cut"?
After running the macro, it stops at "MsgBox oCamera3D.Name", then I have to manually press Enter key on the keyboard in order to have the loop to continue. SendKeys {"ENTER"} does work on 2nd camera display and after.

Any idea?
 
Sorry Ferdo.....

"...Create your own message box form." You mean use MSgBox command to create a message?

Thanks for your help
 
Hi Ferdo.... I am not sure how to start and make an user form since I have never done it before. Could it be made in VB Editor? IF so, how do I start?

Thanks
 
this forum is for CATIA knowledge sharing, it really seems you should also join a VBA forum and search VBA answers there.

get a VBA programming book at the library or buy one.

I might seem rude but trust me I say that for your own good.

Eric N.
indocti discant et ament meminisse periti
 
using Tools / customize you can assign a shortcut to your macro (many video on youtube about that)

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top