bat file into vba (1 Viewer)

ECEK

Registered User.
Local time
Today, 11:51
Joined
Dec 19, 2012
Messages
717
Can anybody point me in the right direction.
At present my VBA code calls a bat file.

This is the bat script

Code:
@ECHO OFF
S:
CD\
CLS
copy /Y "C:\Access Databases\*.accdb" "D:\Access Databases\User1\*.accdb"
copy /Y "C:\Access Databases\*.accdb" "D:\Access Databases\User2\*.accdb"

exit

I need to insert this into my VBA code.
 

ECEK

Registered User.
Local time
Today, 11:51
Joined
Dec 19, 2012
Messages
717
Hi Ranman. I don't want to call the bat file.

I want the bat script as part of my VBA code.
 

Ranman256

Well-known member
Local time
Today, 06:51
Joined
Apr 9, 2015
Messages
4,337
usage:
Copy1File sSrcFile, sTargFile

Code:
Public Sub Copy1File(ByVal pvSrc, ByVal pvTarg)
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile pvSrc, pvTarg
Set FSO = Nothing
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 18:51
Joined
May 7, 2009
Messages
19,234
Also yiu can use the VBA namespace
To change folder:
VBA.CHDir

To copy file:
VBA.FileCopy
 

Users who are viewing this thread

Top Bottom