PDA

Click to See Complete Forum and Search --> : Files


XMortal
Jan 24th, 2000, 02:13 PM
I am in dire need of knowing the syntax for copying files thru VB

i am trying to incorporate a backup function for the database and need to know how to copy it to another file

i also need to know if it is possibe to automate a mail merge thru VB but thats not really a major issue in the program

thanks in advance for any help available

DiGiTaIErRoR
Jan 24th, 2000, 02:33 PM
look at the filecopy funtion in help

------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.

XMortal
Jan 24th, 2000, 02:41 PM
You mean, as in the MSDN stuff??

i dont Have the MSDN libraries, company copy, small machine, no room, no cd

does anyone have an example of filecopy code?

BlackRose
Jan 24th, 2000, 04:06 PM
I think u will b ... good luck

Sub CopyFile(SourceFile As String, DestFile As String)
FileCopy SourceFile, DestFile
End Function

:)

------------------
BlackRose

BlackRose
Jan 24th, 2000, 04:12 PM
if u need something more Pro. try this API
yeh ... I like this one ;)

Create a module and type the following lines in the Declarations section:


Option Explicit

Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
Type the following procedure:


Sub CopyFile(SourceFile As String, DestFile As String)
'---------------------------------------------------------------
' PURPOSE: Copy a file on disk from one location to another.
' ACCEPTS: The name of the source file and destination file.
' RETURNS: Nothing
'---------------------------------------------------------------
Dim Result As Long
If Dir(SourceFile) = "" Then
MsgBox Chr(34) & SourceFile & Chr(34) & _
" is not valid file name."
Else
Result = apiCopyFile(SourceFile, DestFile, False)
End If
End Sub

To test this procedure, type the following line in the Immediate window, and then press ENTER:

CopyFile "<pathNorthwind.mdb>", "C:\Northwind.mdb"


------------------
BlackRose

XMortal
Jan 24th, 2000, 05:41 PM
cheers for the replies