Excel 2007 Macro w/ AppActivate = Run-time error '5': Invalid procedure call or argument

P

Per Moeller-Olsen

Greetings,

Any clue why we get this in an Excel 2007 macro, see below.

Run-time error '5': Invalid procedure call or argument

when running the macro below. The ping starts & runs fine, it's just we get
the error message?

Per...

Sub X_x()
'
' X_x Macro
'
' Keyboard Shortcut: Ctrl+x
'
Dim ReturnValue
ReturnValue = Shell("c:\windows\system32\ping.exe 4.2.2.2 -t")
AppActivate ReturnValue
End Sub
 
J

Jacob Skaria

If you are looking to have the focus on the command window try;

Dim ReturnValue
ReturnValue = Shell("c:\windows\system32\ping.exe 4.2.2.2 -t", vbNormalFocus)

If this post helps click Yes
 
P

Per Moeller-Olsen

With these two lines

On Error Resume Next
AppActivate ReturnValue

rather than just this one

AppActivate ReturnValue

no errors displayed any longer & the stuff is running. It's a little hacked
I think?

I tried your suggestion, did not make any difference as far as I could tell.

Per...
 
C

Chip Pearson

Why not just use

Dim ReturnValue As Long
ReturnValue = Shell("c:\windows\system32\ping.exe -t 4.2.2.2",
vbNormalFocus)


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
P

Per Moeller-Olsen

So no need for AppActivate ReturnValue? Per...

Chip Pearson said:
Why not just use

Dim ReturnValue As Long
ReturnValue = Shell("c:\windows\system32\ping.exe -t 4.2.2.2",
vbNormalFocus)


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top