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
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
677
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:

Forum statistics

Threads
1,077,649
Messages
5,335,489
Members
399,019
Latest member
prab1101

Some videos you may like

This Week's Hot Topics

Top