Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Why is xmove not working? Any ideas?

Hi,

I am attempting to use the DOS Shell command xmove to move all files from one folder to another. I t should be pretty straightforward but it isn't working and I am at a bit of a loss to know why?

Here is the sub:


Public Sub MoveFile(sSourceFile As String, sDestFile As String)

Shell "cmd /c xmove /y " & sSourceFile & " " & sDestFile

End Sub

Here are the inputs:

sSourcePath = ActiveWorkbook.Path & "\Outputs\*.*"
sDestinationPath = "C:\Users\User\Dropbox (Simulytics)\SOFTWARE\data preparation\c DASHBOARD DATABASE PRODUCTION\Inputs"

and here is the call:

Call MoveFile(sSourcePath, sDestinationPath)

Any ideas?

Kind regards, Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Why is xmove not working? Any ideas?

Chances are your source or destination strings have spaces in them, and
so your code is missing some double quotes. You may find it easier to
use VB's FileCopy method along with the Kill statement...

FileCopy sSourceFile, sDestFile
Kill sSourceFile

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Why is xmove not working? Any ideas?

Mark Stephens wrote:

I am attempting to use the DOS Shell command xmove to move all files
from one folder to another. I t should be pretty straightforward but it
isn't working and I am at a bit of a loss to know why?

Here is the sub:


Public Sub MoveFile(sSourceFile As String, sDestFile As String)

Shell "cmd /c xmove /y " & sSourceFile & " " & sDestFile

End Sub

Here are the inputs:

sSourcePath = ActiveWorkbook.Path & "\Outputs\*.*"
sDestinationPath = "C:\Users\User\Dropbox (Simulytics)\SOFTWARE\data
preparation\c DASHBOARD DATABASE PRODUCTION\Inputs"

and here is the call:

Call MoveFile(sSourcePath, sDestinationPath)

Any ideas?


The main problem as I see it is that "xmove" is not a standard command. (It
doesn't exist for me in Win7, 8, or 95.) Are you perhaps thinking of
"xcopy"? Or just normal "move"?

Also, as Garry pointed out, you need to "quote" the filenames. If you *need*
to do this via the shell, change the Shell line to something like this:

Shell "cmd /c xmove /y """ & sSourceFile & """ """ & sDestFile & """"

(Personally, I would do it the way Garry showed.)

--
We can be appropriately immature!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default Why is xmove not working? Any ideas?

On Friday, February 28, 2014 9:17:24 AM UTC+8, GS wrote:
Chances are your source or destination strings have spaces in them, and

so your code is missing some double quotes. You may find it easier to

use VB's FileCopy method along with the Kill statement...



FileCopy sSourceFile, sDestFile

Kill sSourceFile



--

Garry



Free usenet access at http://www.eternal-september.org

Classic VB Users Regroup!

comp.lang.basic.visual.misc

microsoft.public.vb.general.discussion


Thanks a lot Gary, worked like a dream:)
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Why is xmove not working? Any ideas?

Great! Always happy to help...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
Macro stops working when save as xlsm - any ideas? TomCon via OfficeKB.com Excel Programming 3 April 16th 09 12:30 PM
the grab and drag function isn't working in excel any ideas? M Excel Discussion (Misc queries) 1 November 22nd 08 01:11 PM
Function not working (but works as a sub). Any ideas? [email protected] Excel Programming 2 March 7th 06 07:11 PM
VBA Coding - any ideas why this UDFs not working? harpscardiff[_2_] Excel Programming 5 October 12th 05 12:28 PM
Any Ideas? GAIL HORVATH Excel Worksheet Functions 2 May 30th 05 04:17 PM


All times are GMT +1. The time now is 05:57 PM.

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

About Us

"It's about Microsoft Excel"