
December 23rd, 2004, 04:13 PM
|
 |
Contributing User
|
|
Join Date: Aug 2004
Location: Victoria, BC Canada
Posts: 482
Time spent in forums: 1 h 10 m 30 sec
Reputation Power: 5
|
|
Yep, that are go straight to the API
This would go in a module, and you could call it from whereever.
Code:
Option Compare Database
Option Explicit
' This code was originally written by Dev Ashish.
' minorly modified by Mike Walts to generalise it, used
' to be just used for copying the currently open database
' in VBA
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Const FO_MOVE As Long = &H1
Private Const FO_COPY As Long = &H2
Private Const FO_DELETE As Long = &H3
Private Const FO_RENAME As Long = &H4
Private Const FOF_MULTIDESTFILES As Long = &H1
Private Const FOF_CONFIRMMOUSE As Long = &H2
Private Const FOF_SILENT As Long = &H4
Private Const FOF_RENAMEONCOLLISION As Long = &H8
Private Const FOF_NOCONFIRMATION As Long = &H10
Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
Private Const FOF_CREATEPROGRESSDLG As Long = &H0
Private Const FOF_ALLOWUNDO As Long = &H40
Private Const FOF_FILESONLY As Long = &H80
Private Const FOF_SIMPLEPROGRESS As Long = &H100
Private Const FOF_NOCONFIRMMKDIR As Long = &H200
Private Declare Function apiSHFileOperation Lib "Shell32.dll" _
Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) _
As Long
Function fCopyFile(strFileFrom As String, strFileTo As String) As Boolean
Dim tshFileOp As SHFILEOPSTRUCT
Dim lngRet As Long
Dim lngFlags As Long
lngFlags = FOF_SIMPLEPROGRESS Or _
FOF_FILESONLY Or _
FOF_NOCONFIRMATION
With tshFileOp
.wFunc = FO_COPY
.hwnd = hWndAccessApp
.pFrom = strFileFrom
.pTo = strFileTo
.fFlags = lngFlags
End With
lngRet = apiSHFileOperation(tshFileOp)
fCopyFile = (lngRet = 0)
End Function
call it like so
dim lngRet as Long
lngRet = fCopy("PathAndNameOfYour.exe", "PathYouWantItToGoAndNameOfYour.exe")
good luck,
-mwalts
|