Excel Vba Forum - Excelce.Net

SORU ve CEVAPLAR (Yazılabilir) => Microsoft Excel, Vba, Makro, Formül vb. Soruları => Konuyu başlatan: bayramagdaci - 07 Kasım 2016, 15:49:55

Başlık: Excel solveri vba .nete bağlamak
Gönderen: bayramagdaci - 07 Kasım 2016, 15:49:55
Merhabalar exceldeki solveri vba nete bağlamak istiyorum aşağıdaki kodlarda hata veriyor yardımcı olabilir misiniz?

exceldeki kod

Sub Makro1Solver()
Application.Run "Solver.xla!Auto_Open"
SolverReset
Worksheets(1).Select
Worksheets(1).Range("B9").Select
SolverOk SetCell:="R9C2", MaxMinVal:=3, ValueOf:="0", ByChange:="R8C2"
SolverSolve
End Sub


vba daki kod

Dim ExApp As New Microsoft.Office.Interop.Excel.Application
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ExSheet As Microsoft.Office.Interop.Excel.Worksheet

Try
wb = ExApp.Workbooks.Open("E:\Daten\DD-Rechnung.xls")
ExApp.Run("SOLVER.XLA!Auto_Open")

ExApp.DisplayAlerts = True
ExApp.Visible = True
wb.Activate()

ExSheet = ExApp.Worksheets("Tabelle1")
ExSheet.Activate()

ExApp.Run("Tabelle1.Makro1Solver()")

Catch ex As COMException
MessageBox.Show("Error accessing Excel: " + ex.ToString())
Catch ex As Exception
MessageBox.Show("Error: " + ex.ToString())
End Try