Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Invoking "cmd" from VB macro

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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200811/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Invoking "cmd" from VB macro

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

Regards,
Peter T

"Sri via OfficeKB.com" <u47062@uwe wrote in message
news:8d0950ab3f660@uwe...
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

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200811/1




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Invoking "cmd" from VB macro

Thank you very much Peter. It works fine for me...

Sri


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

Regards,
Peter T

Hello all,

[quoted text clipped - 17 lines]

Sri


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200811/1

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
Sending macro based e-mail with built-in "Heading" and "Text" Prabha Excel Programming 3 January 17th 05 02:11 PM
Invoking "#REF!" without hardcoding it Gio Excel Programming 3 November 20th 03 04:19 AM


All times are GMT +1. The time now is 12:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"