Copy Command in Access 2013 VB Issues

PeteB23

New Member
Joined
Oct 26, 2019
Messages
3
Hello.

The following command in an older version of Access used to work:

RetVal = Shell("cmd /c copy /y C:\users\abc\desktop\output.xls C:\users\abc\desktop\split files" & txtDist & ".xls", vbHide)

Copy an output file from access which is working and then moves it to the split file folder and renames it with the variable with .xls.

I am now using Access 2013. I do not get any errors, the script runs, the template (output.xls) gets populated but again, it doesn't copy.

Any suggestions would be great. Below is the entire script.

Additionally, do any references in VB need to be added since I moved this script to 2013?

---

Private Sub Command0_Click()
DoCmd.SetWarnings 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim rs As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rs = db.OpenRecordset("Distributor-IDs", dbOpenTable)
rs.MoveFirst
Do Until rs.EOF
txtDist = rs![APR]
'Set objFolder = objFSO.CreateFolder("C:\users\abc\desktop\Split Files" & txtDist)
DoCmd.OpenQuery "xyz-Output", , acReadOnly
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "xyzoutput", "C:\users\abc\desktop\output.xls", True

RetVal = Shell("cmd /c copy /y C:\users\abc\desktop\output.xls C:\users\abc\desktop\split files" & txtDist & ".xls", vbHide)
rs.MoveNext

Sleep (20000)
Loop
DoCmd.SetWarnings -1
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I would have thought you would need
Rich (BB code):
"C:\users\abc\desktop\split files\"
 


or did the site remove the trailing slash?, as it did when I posted without the code tags?

I would have thought the relevant number version for 2013 should be selected.?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,178
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top