Solved

I want to use XCOPY toand have filenames with spaces.

Posted on 2014-10-30
2
29 Views
Last Modified: 2016-06-22
I am using VBA and a shell comand to move files from one location on the network to another, e.g.

    retval = Shell("XCOPY" & " \\MYSERVER\DATA\D1\D2\D3\Input\Historic\My File.txt ANOTHERSERVER:\TestCopy", 0)

As you can see the filename in this example has a space and the copy fails because of this. I cannot change the filenames because of other dependencies. What is the syntax to use (from with a VBA module to get this to work?


Many thanks

PS this syntax works for filenames without spaces
0
Comment
Question by:fester62
2 Comments
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 500 total points
ID: 40413138
Enclose the file name in quotation marks.

Perhaps something like this to get the quotation marks in there:
    retval = Shell("XCOPY " & """" & "\\MYSERVER\DATA\D1\D2\D3\Input\Historic\My File.txt ANOTHERSERVER:\TestCopy" & """", 0)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question