browse for file and copying to to different folder

S

Sadat

Hello.

In my previous post Douglas helped me a lot about how to put a browse button
on the form and then copying the selected file directly to a folder. Thanks
Douglas for your valuable suggestions. Now I am thinking something different.
Would it be possible to save the files in different folders given that the
name of the folder is taken from a combo or text box. How can it be done? I
am also giving code with which I copy files to a folder.

The Code:

Private Sub Command30_Click()
On Error GoTo Err_Command30_Click

Dim strFIleName As String
Dim strInputFilePath As String
Dim strNewFilePath As String

strInputFilePath = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

strFIleName = Dir(strInputFilePath)
strNewFilePath = "C:\Documents and Settings\smainuddin\My
Documents\Distribution Life Cycle\Compliance and Communication Documentation
Project\Master Folder" & strFIleName

Me.DocumentPath = "#" & strNewFilePath & "#"

If Len(Dir(strNewFilePath)) > 0 Then
' file already exists
If MsgBox(strNewFilePath & " already exists." & vbCrLf & _
"Do you wish to delete it?", vbYesNo + vbQuestion) = vbYes Then
Kill strNewFilePath
End If
End If

FileCopy strInputFilePath, strNewFilePath

Exit_Command30_Click:
Exit Sub

Err_Command30_Click:
MsgBox Err.Description
Resume Exit_Command30_Click

End Sub

Thanks and regards,
Sadat Mainuddin
 
E

ErezM via AccessMonster.com

hi
the code you added is for browsing the computer to find files or folders
if all you need is to copy file A to location B, you write
FileCopy "Full Path\A", "Destination Path\B"

you can change "Destination..." with ComboBox1 or TextBox1

good luck
Erez
 
S

Sadat

thanks Erez for your answer. I thought: strNewFilePath = "C:\......" is the
code for copying file to a destination folder. About your answer...could you
be a little more specific here? I am a newbie. And I would be much more
thankful if you can say how I use that code on what.

Thanks in advance,
Sadat Mainuddin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top