我正在尝试在 Visual Basic for Applications 中编写一个 hello world 应用程序,即修改 Excel 工作表中的单元格。这里是:
Sub hello()
Dim obj As Object
Dim Workbook As Object
Set obj = CreateObject("Excel.Application")
Set Workbook = obj.Workbooks.Open("C:\Users\gbuday\Desktop\Oktatás\Excel\start.xlsx")
Workbook.Worksheets("Munka1").Range("B3") = "Hello World!"
Workbook.Close
Set Workbook = Nothing
Set obj = Nothing
End Sub
运行时,Excel 挂起,我无法停止脚本运行,只能终止 excel 进程。调试它,它挂Workbook.Close
在线上。那条线有什么问题?