错误"用户定义的类型未定义"在访问中创建的vba函数中

时间:2016-10-18 04:41:17

标签: access-vba

我在下面的代码中收到错误user defined type not defined,这是我从目录中选择文件而创建的。此功能将在Ms Access中用于

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "table", **selectFile**, True, "A1:N9000" 

有人可以帮忙吗

Function selectFile()

    Dim fd As FileDialog, fileName As String

 On Error GoTo ErrorHandler

    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    fd.AllowMultiSelect = False

    If fd.Show = True Then
        If fd.SelectedItems(1) <> vbNullString Then
            fileName = fd.SelectedItems(1)
        End If
    Else
        'Exit code if no file is selected
        End
    End If

    'Return Selected FileName
    selectFile = fileName

    Set fd = Nothing

Exit Function

ErrorHandler:
    Set fd = Nothing
    MsgBox "Error " & Err & ": " & Error(Err)

End Function

0 个答案:

没有答案