我使用以下子程序调用shell命令,作为使用excel中的VBA的更大进程的一部分:
Sub runShellScript(ByVal directory As String, command As String)
Dim terminal
Dim output
DoEvents
Application.StatusBar = "Processing data with python...this can take a while"
Set terminal = CreateObject("WScript.Shell")
terminal.Currentdirectory = directory
output = terminal.Run(command, 0, True)
Set output = Nothing
Set terminal = Nothing
End Sub一切都很好,除了我无法让状态栏按我所希望的方式运行。目前,它正确启动(也就是说,状态栏更改为“使用python.处理数据”),但几秒钟后该消息被清除,状态栏恢复到默认的“就绪”状态。更奇怪的是,如果我在任何行停止该函数,它会返回到“用python处理数据.”
显然,这与终端独立于excel实例这一事实有关,但考虑到我的代码正在等待shell脚本完成,我不明白为什么状态栏会被“释放”。
任何修正,或指向正确方向的指针都将不胜感激。
发布于 2013-12-31 13:46:43
试着跟踪微软的例子。它们还操作DisplayStatusBar值:
oldStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Application.StatusBar = "Please be patient..."
Workbooks.Open filename:="LARGE.XLS"
Application.StatusBar = False
Application.DisplayStatusBar = oldStatusBarhttps://stackoverflow.com/questions/20854211
复制相似问题