Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / ActiveX Controls / December 2005

Tip: Looking for answers? Try searching our database.

Copy an open file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel - 20 Nov 2005 16:49 GMT
Hi,

Is there a way to copy an open file ?
Like opening it for Read Only and copy it's contents ?

Thanks,
Alex Dybenko - 20 Nov 2005 16:59 GMT
Hi,
you can use api to do so, look here:
http://www.mvps.org/access/api/api0026.htm

Signature

Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Hi,
>
> Is there a way to copy an open file ?
> Like opening it for Read Only and copy it's contents ?
>
> Thanks,
John Mishefske - 22 Nov 2005 07:09 GMT
> Hi,
>
> Is there a way to copy an open file ?
> Like opening it for Read Only and copy it's contents ?

No opinion on whether this is something you should do...

Private Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" ( _
    ByVal lpExistingFileName As String, _
    ByVal lpNewFileName As String, _
    ByVal bFailIfExists As Long) As Long

' Replacement for FileCopy command that allows an open file to be copied.
' Of course - you want to be careful using this since any change to the
' file while copying it can leave the new copy corrupted.
'
' from http://support.microsoft.com/default.aspx?scid=kb;EN-US;207703
Public 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 Len(Dir(SourceFile)) = 0 Then
        MsgBox Chr(34) & SourceFile & Chr(34) & " is not valid file name.", _
            vbOKOnly Or vbExclamation, App.Title
    Else
        ' important - don't allow a "copy over" - it may destroy data
        Result = apiCopyFile(SourceFile, DestFile, True)   ' 3rd param - FailIfExists
    End If

End Sub

Signature

'---------------
'John Mishefske
'---------------

Alex Arkhipov - 18 Dec 2005 02:42 GMT
Try selecting everything and press Control+C.
> Hi,
>
> Is there a way to copy an open file ?
> Like opening it for Read Only and copy it's contents ?
>
> Thanks,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.