老师,代码如下:
Private Sub Upload_Click()
On Error GoTo Err_cmdPhoto_Click
Dim fso As Object
Dim s_filepath, strFileName, s_fileName, s_fullname, s_newFile, ServerPath As String
ServerPath = g_Server & "\NDA\"
With Application.FileDialog(3)
.Filters.Clear
.Filters.Add "(*.*)All Files", "*.*"
If .Show Then strFileName = .SelectedItems(1)
End With
If Not IsNull(strFileName) And Len(strFileName) > 0 Then
s_fileName = ServerPath & Mid(strFileName, InStrRev(strFileName, "\") + 1)
MsgBox "Attachment has been upload to:" & s_fileName
s_fullname = Mid(strFileName, InStrRev(strFileName, "\") + 1)
s_newFile = "Copy_" & s_fullname
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(s_fileName) = True Then
If MsgBox("fileName exists,Are you sure to overwriter?If not, please change the file name and try again", vbOKCancel + vbInformation, "ìáê¾") = vbOK Then
FileCopy strFileName, s_fileName
Me.fj = s_fullname
Else
Exit Sub
End If
Else
FileCopy strFileName, s_fileName
Me.fj = s_fullname
End If
Set fso = Nothing
End If
Exit_cmdPhoto_Click:
Exit Sub
Err_cmdPhoto_Click:
MsgBox "#" & Err & " " & Err.Description, vbCritical, "3ö′í"
Resume Exit_cmdPhoto_Click
End Sub
NDA这个文件夹我放在平台文件夹里面。。。