如题所述
第1个回答 2019-07-24
Chr(34)就是英文双引号,比如,你可以这样写:
shell
"cmd.exe
/c
"
&
chr(34)
&
CommonDialog.filename
&
chr(34)
总之就是把路径用引号括起来就不存在空格问题了
shell
"cmd.exe
/c
"
&
chr(34)
&
CommonDialog.filename
&
chr(34)
总之就是把路径用引号括起来就不存在空格问题了
第2个回答 2019-02-02
function
shellEx(vCommand
As
string,vOptions
as
string,Optional
rMode
as
VbAppWinStyle
=vbMinimizedFocus)
as
Double
dim
p
as
string
p=vOptions
If
Instr(p,"
")>0
then
p=Chr(34)
&
p
&
Chr(34)
p=vCommand
&
"
"
&
p
shellEx=Shell(p,rMode)
end
function
调用的你的例子的话是:
ShellEx
"cmd.exe
/c","d:\a
a\a.txt"
这个只支持一个参数,如果须要我可以写成多个的参数
shellEx(vCommand
As
string,vOptions
as
string,Optional
rMode
as
VbAppWinStyle
=vbMinimizedFocus)
as
Double
dim
p
as
string
p=vOptions
If
Instr(p,"
")>0
then
p=Chr(34)
&
p
&
Chr(34)
p=vCommand
&
"
"
&
p
shellEx=Shell(p,rMode)
end
function
调用的你的例子的话是:
ShellEx
"cmd.exe
/c","d:\a
a\a.txt"
这个只支持一个参数,如果须要我可以写成多个的参数