I know this can be done manually by a right mouse click. But I was wondering if there exists VBA code that will copy and paste my current DB someplace, I figure without shutting down the current DB if possible.
This will do it. Each do loop is just to give time for each procedure to complete befire sending a new command.
Option Explicit
Private Sub Form_Load()
Dim Pausetime, Start, Program
'Load Explorer
Program = Shell("c:\windows\explorer.exe", 1)
' wait for procedure to complete
Pausetime = 5
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
'Copy Db
SendKeys "%d" 'Goto address line
' wait for procedure to complete
Pausetime = 2
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "\dbdirectory"
' wait for procedure to complete
Pausetime = 2
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "{enter}"
' wait for procedure to complete
Pausetime = 2
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "%ea" 'highlight all, or you could put in just the name of the database
' wait for procedure to complete
Pausetime = 2
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "%ec" 'copy
' wait for procedure to complete
Pausetime = 2
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "%d" 'change directories
' wait for procedure to complete
Pausetime = 1
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
' wait for procedure to complete
Pausetime = 1
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "{enter}"
' wait for procedure to complete
Pausetime = 5
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "%ep" 'paste web site
' wait for procedure to complete
Pausetime = 5
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "a" 'to replace all files
' wait for procedure to complete
Pausetime = 15 ' time to actually paste the file
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "%f" 'close explorer
' wait for procedure to complete
Pausetime = 1
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
SendKeys "c"
' wait for procedure to complete
Pausetime = 5
Start = Timer ' Set start time.
Do While Timer < Start + Pausetime
DoEvents ' Yield to other processes.
Loop
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.