FileCopy Bad File Name or number

  • Thread starter Thread starter mikesjLFG
  • Start date Start date
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
 
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.
 
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
 
Back
Top