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つの参照のみを使用しています。アクセス; とDAO。

于 2012-04-06T18:39:55.813 に答える