简体   繁体   中英

Vba Shell call works with some programs but does not work with others

Shell call works with some programs that I have but does not work with others. I am putting the most basic call here for opening an exe without any further commands

Shell "C:\Program Files\qBittorrent\qbittorrent.exe", 1 'works
Shell "C:\Program Files\AmiBroker\Broker.exe", 1 'works
Shell "C:\Program Files\CTrading\QuantShare\QuantShare.exe", 1 'Run-time error '5': Invalid procedure call or argument
Shell "C:\Program Files (x86)\Equis\MetaStock\MsWin.exe", 1 'same error

I am on the verge of giving up unless I meet a savior here!!
System: Windows 10 Pro Version 1909 OS Build 18363.476
Microsoft Excel 2013 64-bit

A bit of an ugly fix, but it might help:

Shell "cmd /c ""C:\Program Files\CTrading\QuantShare\QuantShare.exe""", 1

I don't have any of the programs you are having problems with, so it is a bit of a guess. If this doesn't help, the next step is cmd /c start ...

Finally, i could use ShellExecute as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A1:A2000")) Is Nothing Then
Set objShell = CreateObject("Shell.Application")
para = "TaskManager ChangeSymbol newsymbol:" & ActiveCell.Value
objShell.ShellExecute "C:\Program Files\CTrading\QuantShare\QuantShare.exe", para, "", "open", 1
Set objShell = Nothing
Cancel = True
End If
End Sub

Can I make ShellExecute not to open a new instance of the program and rather activate the currently open instance and pass the arguments (similar to Shell call? Also how to make ShellExecute not take focus? I want the focus to stay back in Excel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM