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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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