1

我创建了一个作为 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
4

1 回答 1

2

如果您删除项目的 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供生产使用,然后继续在代码中按名称使用它们。

我不知道所有其他参考是什么。建议您复制您的项目,删除所有这些引用,看看当您Debug->Compile从 VB 编辑器的主菜单运行时会发生什么。不选中任何不需要的参考。并尝试对其余部分进行后期绑定。我在 Access 应用程序的生产版本中只使用了 3 个引用:VBA;使用权; 和 DAO。

于 2012-04-06T18:39:55.813 回答