Invoking "cmd" from VB macro

  • Thread starter Sri via OfficeKB.com
  • Start date
S

Sri via OfficeKB.com

Hello all,

I want to execute following dos command in my XL VB macro.
dir C:\Project\Test_Cases /s > C:\TEMP_TEST_CASE_ROOT_XXX\files.txt

If C:\Project\Test_Cases will be in a variable FName then the following
command is perfectly working fine for me.

x = Shell("cmd.exe /c dir " & FName & " /s > C:\TEMP_TEST_CASE_ROOT_XXX\files.
txt", vbHide)

The problem comes if my FName has a space in it. For example, if FName is C:\
Project\Test Cases then the above command is not working.

How to append " symbol as prefix and suffix to my variable FName.

Any help please ???

Sri
 
P

Peter T

FName = """c:\ the path"""
or
FName = chr(34) & "c:\ the path" & chr(34)

Regards,
Peter T
 

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