FileCopy Bad File Name or number

M

mikesjLFG

I am using an API so the user can select a file from their computer,
it will then copy the file over to the network so that it will be
accessible from any machine that has permission to the file. (The new
filename should be the uniqueID with proper extension) There might be
a much simpler way to do this, but I wasn't aware of it so I am trying
this way and getting the error.

Private Sub Command25_Click()

Dim strFilter As String
Dim strInputFileName As String
Dim strFileCopyFrom As String
Dim strFileCopyTo As String

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select Resume to upload...", _
Flags:=ahtOFN_HIDEREADONLY)

FileCopyFrom = """" & strInputFileName & """"
FileCopyTo = """" & "\\server\share\" & ID.Value &
Right(strInputFileName, 4) & """"
FileCopy FileCopyFrom, FileCopyTo
 
G

Guest

The following works for me.

****
Dim strFilter As String
Dim lngFlags As Long
Dim strInputFileName As String
Dim strFileCopyFrom As String
Dim strFileCopyTo As String

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
lngFlags = ahtOFN_HIDEREADONLY
strInputFileName = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, Flags:=lngFlags, _
DialogTitle:="Please select Resume
to upload...")

strFileCopyFrom = """" & strInputFileName & """"
strFileCopyTo = """" & "\\server\share\" & _
Right(strInputFileName, 4) & """"
FileCopy strFileCopyFrom, strFileCopyTo
****

You do have a module with the API code
(http://www.mvps.org/access/api/api0001.htm), right! Also, it wouldn't work
for whatever reason, I did a debug and a compact and repair and everything
works fine now.
 
M

mikesjLFG

I tried your code also and it still failed to work...

However... I did find a solution. By simply removing the """" it works
fine. I was thinking it was like the DOS based copy where quotes
would be needed if a space was in the file name.

Thanks for all of your help!
Mike
 

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