这是子
Sub test()
With ThisWorkbook
.Worksheets("Sheet1").Range("A1").Value = 5
.Save
End With
End Sub
这是启动sub
的vbscriptdim eApp
set eApp = GetObject("C:\Users\Owner\Desktop\Book1.xlsm")
eApp.Application.Run "Book1.xlsm!test"
set eApp = nothing
它执行正常,但工作簿由于某种原因被隐藏。我必须取消隐藏View - -> Unhide
为什么会发生这种情况以及如何解决这个问题
答案 0 :(得分:2)
更清晰地运行vbs
的方式如下
Dim ObjExcel, ObjWB
Set ObjExcel = CreateObject("excel.application")
Set ObjWB = ObjExcel.Workbooks.Open("C:\Users\Owner\Desktop\Book1.xlsm")
'make it visible
ObjExcel.Visible = True
ObjExcel.Run "Book1.xlsm!test"
ObjWB.Close False
ObjExcel.Quit
Set ObjExcel = Nothing