Access交流中心

北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |

[5分]上传、下载、打开文件到指定文件夹

陈琳  发表于:2013-04-11 10:06:20  
复制

    老师,我增加一个功能叫上传、下载、打开文件到指定文件夹。

    点上传的时候出现以下问题。我是单机版的,不知道是因为服务器没设置好呢,还是代码有问题,没找出来问题。。。

    麻烦老师指导一下。

 

Top
杜超-2号 发表于:2013-04-11 10:13:31
路径不正确

陈琳 发表于:2013-04-11 10:23:44

老师,代码如下:

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这个文件夹我放在平台文件夹里面。。。



总记录:2篇  页次:1/1 9 1 :