我正在为Visual Basic 2010.NET中的SaveFile对话框编写以下代码。在创建XLSX文件并在Microsoft Excel中打开时,代码运行良好。但是,我遇到的问题是,如果程序覆盖文件,则用户会收到两个提示。一个提示来自程序自己的SaveFile对话框,确认选择。另一个来自Microsoft Excel,问你一样。就像程序在后台运行一样。
有谁知道如何编写此代码以将文件另存为Excel文件?
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Frm1
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim rowcounter As Integer = 1
xlApp = New Excel.Application
xlApp.Visible = False
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("Sheet1")
xlWorkSheet.Cells(rowcounter, rowcounter) = "Something goes here."
xlWorkSheet.SaveAs(SaveXLS.FileName)
xlWorkBook.Close()
xlApp.Quit()
End Class