Ms access 将数据库导出到其他计算机时出错

Ms access 将数据库导出到其他计算机时出错,ms-access,vba,Ms Access,Vba,我已经创建了一个数据库,它安装在一个作为epos系统运行的安装程序中 在其他计算机上安装它时,我收到大量错误,都是说缺少了一些东西。该文件在我的计算机上运行良好,但这些错误会阻止任何东西在其他计算机上工作 错误如下。每个都有自己的弹出框 broken reference to excel.exe version 1.7 or missing. acwztool.accde missing npctrl.dll v4.1 missing contactpicker.dll v1.0 missing

我已经创建了一个数据库,它安装在一个作为epos系统运行的安装程序中

在其他计算机上安装它时,我收到大量错误,都是说缺少了一些东西。该文件在我的计算机上运行良好,但这些错误会阻止任何东西在其他计算机上工作

错误如下。每个都有自己的弹出框

broken reference to excel.exe version 1.7 or missing.
acwztool.accde missing
npctrl.dll v4.1 missing
contactpicker.dll v1.0 missing
cddbcontolwinamp.dll v1.0 missing
cddbmusicidwinamp.dll v1.0 missing
colleagueimport.dll v1.0 missing
srstsh64.dll missing
我觉得这可能是因为我修改了模块vba库引用,以便可以运行使用excel的vba代码,不幸的是,我忘记了添加了哪些库

如果有帮助,下面是我添加的需要新引用的代码

Public Sub SalesImage_Click()
Dim rst As ADODB.Recordset

' Excel object variables
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlChart As Excel.Chart

Dim i As Integer

On Error GoTo HandleErr

' excel aplication created
Set xlApp = New Excel.Application

' workbook created
Set xlBook = xlApp.Workbooks.Add

' set so only one worksheet exists
xlApp.DisplayAlerts = False
For i = xlBook.Worksheets.Count To 2 Step -1
    xlBook.Worksheets(i).Delete
Next i
xlApp.DisplayAlerts = True

' reference the first worksheet
Set xlSheet = xlBook.ActiveSheet

' naming the worksheet
xlSheet.name = conSheetName

' recordset creation
Set rst = New ADODB.Recordset
rst.Open _
 Source:=conQuery, _
 ActiveConnection:=CurrentProject.Connection

With xlSheet
    ' the field names are imported into excel and bolded
    With .Cells(1, 1)
        .Value = rst.Fields(0).name
        .Font.Bold = True
    End With
    With .Cells(1, 2)
        .Value = rst.Fields(1).name
        .Font.Bold = True
    End With

    ' Copy all the data from the recordset into the spreadsheet.
    .Range("A2").CopyFromRecordset rst

    ' Format the data the numbering system has been extended to encompas up to 9,999,999 sales to cover all posibilities of sales since the last stock take
    .Columns(1).AutoFit
    With .Columns(2)
        .NumberFormat = "#,###,###"
        .AutoFit
    End With
End With

' Create the chart.
Set xlChart = xlApp.Charts.Add
With xlChart
    .ChartType = xl3DBarClustered
    .SetSourceData xlSheet.Cells(1, 1).CurrentRegion
    .PlotBy = xlColumns
    .Location _
     Where:=xlLocationAsObject, _
     name:=conSheetName
End With

'the reference must be regotten as it is lost
With xlBook.ActiveChart
    .HasTitle = True
    .HasLegend = False
    With .ChartTitle
        .Characters.Text = conSheetName & " Chart"
        .Font.Size = 16
        .Shadow = True
        .Border.LineStyle = xlSolid
    End With
    With .ChartGroups(1)
        .GapWidth = 20
        .VaryByCategories = True
    End With
    .Axes(xlCategory).TickLabels.Font.Size = 8
    .Axes(xlCategoryScale).TickLabels.Font.Size = 8
 End With

 With xlBook.ActiveChart
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Product"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Sales"
End With

 'format the size and possition of the chart
With xlBook.ActiveChart
    .Parent.Width = 800
    .Parent.Height = 550
    .Parent.Left = 0
    .Parent.Top = 0
End With

'this displays the chart in excel. excel must be closed by the user to return to the till system
xlApp.Visible = True

ExitHere:
On Error Resume Next
'this cleans the excel file
rst.Close
Set rst = Nothing
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Exit Sub

HandleErr:
MsgBox Err & ": " & Err.Description, , "There has been an error!"
Resume ExitHere

End Sub

如果删除项目的Excel引用并对Excel对象使用后期绑定,部署应该不会那么麻烦

缺点是在后期绑定的开发过程中失去了Intellisense的好处。但是,在开发过程中很容易在早期绑定和生产过程中的后期绑定之间切换。只需更改编译器常量的值

在模块的声明部分

    #Const DevStatus = "PROD" 'PROD or DEV
然后在程序体中

    #If DevStatus = "DEV" Then
        Dim xlApp As Excel.Application
        Dim xlBook As Excel.Workbook
        Dim xlSheet As Excel.Worksheet
        Set xlApp = New Excel.Application
    #Else ' assume PROD (actually anything other than DEV)
        Dim xlApp As Object
        Dim xlBook As Object
        Dim xlSheet As Object
        Set xlApp = CreateObject("Excel.Application")
    #End If
对于后期绑定,您的代码将需要使用Excel常量的值,而不是常量名称。或者,您可以在
#Else
块中定义命名常量以供生产使用,然后继续在代码中按名称使用它们


我不知道其他的参考资料是什么。建议您复制一份项目,删除所有这些引用,并查看在VB编辑器主菜单中运行
Debug->Compile
时会发生什么。不选中任何不需要的引用。其余的试试晚装。在Access应用程序的生产版本中,我只使用了3个参考:VBA;通道还有DAO。

谢谢你的回答,我对这件事有点惊慌失措,因为我必须在几周内交上来。你知道我在哪里可以得到access中包含的基本引用列表吗。我正在考虑重新安装access,因为我认为它会重置库引用并从那里开始工作。我将在明天有时间查看时尝试此功能。无需重新安装Access来解决此问题。创建一个新的数据库,看看你得到了哪些引用。除了我提到的3个,您还可以获得OLE自动化;我取消选中该选项,并没有发现任何问题。如果使用Access2007创建新的ACCDB格式数据库,则将获得Access数据库引擎库而不是DAO。如果你的学校访问版本是2003年或更早,那么这种参考差异不应该是一个问题,因为那些较旧的访问版本首先不能处理ACCDB。我希望回复是令人满意的。我想鼓励你自己保持这个简单。如果您想了解更多关于细节的信息,请参阅Access MVP的Doug Steele对该主题的看法:现在我一直得到一个424错误:需要对象。我是否需要将所有的xlapp、xlbook、xlchart、xlsheet重命名为objapp、objbook、objchart、objsheet来完成这项工作?很抱歉,我以前没有讨论过这类问题……我想让您使用自己的变量名来代替我的变量名。我更新了代码示例以使用您的一些名字。如果你有别的意思,请告诉我。