Need Help: Open File List and then Copy Selected File

apinshot

New member
Local time
Today, 16:00
Joined
Oct 4, 2007
Messages
7
I'm using the following code (found here, and it works great!) to search for an open a file. It lists every file in a directory which is exactly what I want.

I've tried without success to build on this code to open the file list and then after a file is selected copy that file to a new directory. Any advice?

I've tried replacing the line "Application.FollowHyperlink cPath & "\" & cbSelectFile" with a FileCopy command but I can't seem to figure it out.

Thanks!


Option Compare Database
Option Explicit

'Combo box named [cbSelectFile]
'Row Source Type set to [Value List]

Const cPath = "C:\Temp\" 'cPath must end with a back slash i.e. C:\Temp\

Private Sub cbSelectFile_AfterUpdate()
On Error GoTo Err_cbSelectFile_AfterUpdate
Me.tbHidden.SetFocus
Application.FollowHyperlink cPath & "\" & cbSelectFile
Exit_cbSelectFile_AfterUpdate:
Exit Sub

Err_cbSelectFile_AfterUpdate:
If Err.Number = 432 Then 'File name or class not found during Automation operation
MsgBox "The '" & cbSelectFile & "' file can not be copied.", vbCritical, "Invalid File Type"
Exit Sub
Else
MsgBox Err.Number & " - " & Err.Description
Resume Exit_cbSelectFile_AfterUpdate
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom