Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When I use AppActivate to set focus to a console window started with
Shell, I receive runtime error 5. This doesn't occur when I put a break point on the AppActivate statement and then resume. dblPID = Shell("cmd.exe /k", vbNormalFocus) AppActivate dblPID ' Runtime error 5 Is this a bug? I also tried putting in a for-next loop to insert a delay between the statements. And in the real program, I have several statements between the Shell and the AppActivate statements. I'm trying to get the VBA code to wait for the shell call to complete before certain statements get executed. Do I have to resort to using an API shell call? I'm running Win2000 SP4, Office 2000 SP3. Here's some simple code that demonstrates how I think this should work, but note that the real code uses the /c switch to cmd and includes several statements between the Shell and AppActivate calls: Private Sub cmdOK_Click() Dim dblMinVal As Double dblMinVal = Shell("cmd.exe /K", vbNormalFocus) On Error Resume Next Do AppActivate dblMinVal If Err.Number = 5 Then ' Console closed Err.Clear Exit Do End If Loop On Error GoTo 0 MsgBox "You shouldn't see this message until " & _ "you close the console window, but you do!" Unload frmMain End Sub 'cmdOK_Click() (Note that my real email address is rzeitler AT phonon DOT com.) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
xpath error? Runtime Error 13 type mismatch | Excel Discussion (Misc queries) | |||
Runtime error '1004' General ODBC error | New Users to Excel | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Syntax Error Runtime Error '424' Object Required | Excel Programming | |||
Unknown where is the problem on the Runtime error - Automation error | Excel Programming |