Ich kann Excel-Blatt durch eine Anwendung nicht speichern Ich habe in Vb 2010.It ist in der Lage, eine Datei zu erstellen und gibt alle Daten zugewiesen aber gibt eine COM-Ausnahme nicht behandelt, wenn es trifft der Save-Befehl: -
xlWorkBook.SaveAs ("C: \ ABC", "xlsx")
ich Verweise hinzugefügt habe in meinem Visual Studio Excel 2010nicht speichern Excel-Blatt über Vb2010
Unten ist der Code ich verwende: -
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim xlApp As New Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
'Add a New Workbook
xlWorkBook = xlApp.Workbooks.Add
'Display Excel
xlApp.Visible = False
'Set the relebant sheet that we want to work with
xlWorkSheet = xlWorkBook.Sheets("Sheet1")
With xlWorkSheet
'Directly type the values that we want
.Range("A1").Value = "Company Name"
.Range("A2").Value = "Product Name"
.Range("A3").Value = "Budget"
.Range("A4").Value = "Expected Delivery"
.Range("B1").Value = "hi"
.Range("B2").Value = "hh"
.Range("B3").Value = "qw"
.Range("B4").Value = "qw"
End With
'Save the file
xlWorkBook.SaveAs("C:\ABC", "xlsx")
'Close the file
'xlWorkBook.Close()
End Sub
Haben Sie Ihre Anwendung "Als Administrator" ausgeführt? –