0

我的目标是尝试弹出保存或打开已创建文件的选项。

这是我的代码:

 Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet
        Dim misValue As Object = System.Reflection.Missing.Value

        xlApp = New Excel.ApplicationClass
        xlWorkBook = xlApp.Workbooks.Add(misValue)
        xlWorkSheet = CType(xlWorkBook.Sheets("sheet1"), Excel.Worksheet)
        xlWorkSheet.Cells(1, 1) = "PERIOD"
        xlWorkSheet.Cells(1, 2) = "PARTS_NO_FG"
        xlWorkSheet.Cells(1, 3) = "QTY_ASSY"
        xlWorkSheet.Cells(1, 4) = "COSTING1"

        xlWorkSheet.Cells(2, 1) = "201212"
        xlWorkSheet.Cells(2, 2) = "01125E6041"
        xlWorkSheet.Cells(2, 3) = "5"
        xlWorkSheet.Cells(2, 4) = "0"


        xlWorkSheet.SaveAs("D:\TemplateAssy.xlsx")

        xlWorkBook.Close()
        xlApp.Quit()
        releaseObject(xlApp)
        releaseObject(xlWorkBook)
        releaseObject(xlWorkSheet)

那么当我执行这个程序VB.NET时如何弹出谢谢

4

1 回答 1

2

只需打开警报。它应该可以解决问题

 Application.DisplayAlerts = True

 workbook.SaveAs(filePath)

 Application.DisplayAlerts = True

来源: http: //p2p.wrox.com/vb-how/63900-disabling-second-excel-save-prompt.html

shasur的回复

编辑:在你的情况下

 xlApp.DisplayAlerts = True

 xlWorkbook.SaveAs(filePath)

 xlApp.DisplayAlerts = True

也试试 xlApp.Visible = True

也许可以为您提供有关其未出现的位置/原因的指示。

于 2013-04-29T20:54:36.077 回答