Solved

I want to use XCOPY toand have filenames with spaces.

Posted on 2014-10-30
2
33 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

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.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …

738 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