Thank!
Alberto Rausa
Try the article Q102671 in Microsoft's Support site.
btw it's called Access Basic in version 2.0, not VBA.
HTH
--
Just my $.001
Dev Ashish
---------------
The Access Web ( http://home.att.net/~dashish )
---------------
Alberto Rausa wrote in message <34e9b922...@news.tin.it>...
:Can i copy a file from VBA and Access2?
:
:Thank!
:
: Alberto Rausa
Dim SourceFile As String
Dim DestinationPath As String
Dim MyFile As String
Dim Message As String
CommonDialog1.Flags = &H1000 Or &H4
CommonDialog1.DialogTitle = "Copy Template"
CommonDialog1.InitDir = [Forms]![Admin Menu]![PTH]
CommonDialog1.FileName = "*.doc"
CommonDialog1.Filter = "Word 7.0 Document (*.doc)|*.doc"
CommonDialog1.ShowSave
CommonDialog1.DefaultExt = "doc"
SourceFile = CommonDialog1.FileName
DestinationPath = CommonDialog1.FileTitle
MyFile = Dir([Forms]![Admin Menu]![PTH] & DestinationPath)
If MyFile = CommonDialog1.FileTitle Then
Message = CommonDialog1.FileTitle & " already
exists in this directory. Overwrite?"
If MsgBox(Message, vbYesNo, "Error!") = vbYes Then
On Error Resume Next
[Forms]![Categories]![TestFileName] =
CommonDialog1.FileTitle
FileCopy SourceFile, [Forms]![Admin Menu]![PTH] &
DestinationPath
DoCmd.Close acForm, "Categories", acSaveYes
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,
acMenuVer70
End If
Else
On Error Resume Next
If CommonDialog1.FileTitle <> "" Then
[Forms]![Categories]![TestFileName] =
CommonDialog1.FileTitle
FileCopy SourceFile, [Forms]![Admin Menu]![PTH]
& DestinationPath
DoCmd.Close acForm, "Categories", acSaveYes
Else
End If
End If
filecopy source, dest
Michael
D Paul Phillips <dpph...@mail.delcoelect.com> wrote in message
news:34EC8D...@mail.delcoelect.com...
Sub CopyFile (pstrSrc As String, pstrTarget As String)
On Error GoTo CopyFile_Err
Dim hfInput As Integer
Dim hfOutput As Integer
Dim lngFilePointer As Long
Dim lngRemain As Long, lngFileLen As Long
Dim strBuffer As String
Dim J As Integer
Dim varDummy As Variant
' Size of buffer to use while copying
Const BYTE_SIZE = 20480
DoCmd Hourglass True
hfInput = FreeFile
' open source file
Open pstrSrc For Binary Access Read Shared As #hfInput
hfOutput = FreeFile
If Len(Dir(pstrTarget)) Then
' Overwrite tartget if exists
Kill pstrTarget
End If
Open pstrTarget For Binary Access Read Write Lock Read Write As
#hfOutput
' Length of file
lngRemain = LOF(hfInput)
lngFileLen = lngRemain
varDummy = SysCmd(SYSCMD_INITMETER, "Copying", lngFileLen)
lngFilePointer = 1
Do Until lngRemain < BYTE_SIZE
strBuffer = Input(BYTE_SIZE, #hfInput)
Put #hfOutput, lngFilePointer, strBuffer
lngRemain = lngRemain - BYTE_SIZE
lngFilePointer = lngFilePointer + BYTE_SIZE
varDummy = SysCmd(SYSCMD_UPDATEMETER, lngFilePointer)
DoEvents
Loop
strBuffer = Input(lngRemain, #hfInput)
Put #hfOutput, lngFilePointer, strBuffer
lngFilePointer = lngFilePointer + lngRemain
varDummy = SysCmd(SYSCMD_UPDATEMETER, lngFilePointer)
DoEvents
Close #hfInput
Close #hfOutput
CopyFile_Exit:
On Error Resume Next
Close #hfInput
Close #hfOutput
DoCmd Hourglass False
varDummy = SysCmd(SYSCMD_REMOVEMETER)
Exit Sub
CopyFile_Err:
Select Case Err
Case Else
End Select
' Retry/Abort/Ignore
Select Case MsgBox(Error, MB_ABORTRETRYIGNORE Or MB_ICONEXCLAMATION,
"Error " & Err)
Case IDABORT
Resume CopyFile_Exit
Case IDRETRY
Resume
Case IDIGNORE
Resume Next
End Select
Exit Sub
End Sub
\|||/
/ \
C o o D
-----------------ooO--u--Ooo-------------------------------
To reply my mail, replace the "nospam" in my address with "trevor",
this was put on in defence of the spam robots that roam usenet.
MS Access FAQ now available on my site below.
http://easyweb.easynet.co.uk/~trevor/
Apathy Error: Don't bother striking any key.