刷新数据并退出并保存宏Excel [英] Refresh data and exit with saving Macro Excel
问题描述
我需要刷新来自ole db source的数据,同时打开保存并退出的excel和afte。
这是我的宏代码:
I need to refresh the data from ole db source while opens excel and afte that saves and exit. Here is my macro code:
Sub auto_open()
Call DataRefresh
End Sub
Sub DataRefresh()
TimeToRun = Now
Application.OnTime TimeToRun, "Refresh"
End Sub
Sub Refresh()
ActiveWorkbook.Connections("Shas").Refresh
End Sub
Sub auto_close()
Application.OnTime TimeToRun, "Refresh", , True
Application.Quit
ThisWoorkbook.Close SaveChanges:=True
End Sub
可以在开放后更新,但不会退出。我做错了什么?
It's okay with renewing after openening but it doesnt exit. What am I doing wrong?
推荐答案
你实际上并没有告诉工作簿在任何时候关闭...
You don't actually tell the workbook to close at any point...
此外,Auto_Open()例程在技术上触发 工作簿已经完成打开,因此您不需要调用单独的例程:
Also, the Auto_Open() routine is technically triggered after the workbook has finished opening so you don't need to call separate routines:
另外 - 您退出应用程序后无法关闭工作簿...
Also Also - You can't close a workbook after you've quit the application...
:
Sub auto_open()
ActiveWorkbook.Connections(Shas)刷新
DoEvents
ThisWoorkbook 。关闭SaveChanges:= True
End Sub
这篇关于刷新数据并退出并保存宏Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!