2012-04-06 12 views
1

エポスシステムとして実行されるインストーラに含まれるデータベースを作成しました。データベースを他のコンピュータにエクスポートするときにエラーが発生する

他のコンピュータにインストールすると、何かが見つからないというエラーが多数表示されます。ファイルはコンピュータで完全に実行されますが、エラーによって他のコンピュータで作業が停止します。

エラーは次のとおりです。それぞれに独自のポップアップボックスがあります。

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 

私はこのように感じることがあり、私はExcelを使用するVBAコードを実行することができるように、私は、残念ながら私はそれが助け場合、私は

を追加しているlibrarys忘れてしまった、モジュールの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 

答えて

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に名前付き定数を定義して、引き続きコード内で名前で使用することができます。

他のすべての参照が何であるか分かりません。 VB EditorのメインメニューからDebug->Compileを実行すると、プロジェクトのコピーを取り、それらの参照をすべて削除し、何が起こるかを確認することをお勧めします。不要な参照はチェックしないでください。そして残りの時間を遅く締めてみてください。実用バージョンのAccessアプリケーションでは、3つの参照のみを使用します。アクセス;とDAO。

+0

答えをありがとう、私は数週間でそれを手渡さなければならないので、私はこれをかなりパニックにしていた。 あなたは、私がアクセスに含まれるベースリファレンスのリストをどこで得ることができるか分かっていますか?私は、ライブラリ参照をリセットしてそこから作業すると考えていたので、アクセスを新しくインストールすることを考えていました。私はそれを見る時間があるときに明日これを試してみるでしょう。 –

+1

再インストールする必要はありません。これをソートする必要はありません。新しいデータベースを作成し、取得した参照を確認します。私が言及した3に加えて、あなたはOLEオートメーションを得るかもしれません。私はそれをオフにして何の問題に気づいていない。 Access 2007を使用して新しいACCDB形式のデータベースを作成する場合は、DAOの代わりにAccessデータベースエンジンライブラリを入手します。あなたの学校のAccessバージョンが2003年以前の場合、古いバージョンのAccessバージョンでは最初にACCDBに対応できないため、その違いは問題ではありません。 – HansUp

+1

私は応答が満足であることを願っています。私はあなたにこれを簡単に保つように奨励しようとしています。詳細についてもっと知りたい場合は、そのトピックについてDoug Steele、Access MVPが言っていることを参照してください。http://www.accessmvp.com/djsteele/accessreferenceerrors.html – HansUp

関連する問題