如何从Outlook宏运行Excel宏? [英] How can I run an Excel macro from an Outlook macro?
本文介绍了如何从Outlook宏运行Excel宏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从Outlook宏运行Excel宏?
解决方案
您将需要添加Microsoft Excel 14.0数据对象库。转到工具 - >参考。
您还需要打开该工作簿才能从中运行宏。
这应该工作:
Dim ExApp As Excel.Application
/ pre>
Dim ExWbk As Workbook
Set ExApp = New Excel.Application
Set ExWbk = ExApp.Workbooks.Open(C:\Folder\Folder\File.xls)
ExApp.Visible = True
ExWbk.Application.RunModuleName.YourMacro
ExWbk.Close SaveChanges:= True
如果要在后台运行此宏,而不打开Excel的可见实例,请将ExApp.Visible设置为False。
How can I run an Excel macro from an Outlook macro?
解决方案You will need to add the Microsoft Excel 14.0 Data Objects library. Go to Tools -> References.
You will also need to open the workbook before you can run a macro from it.
This should work:
Dim ExApp As Excel.Application Dim ExWbk As Workbook Set ExApp = New Excel.Application Set ExWbk = ExApp.Workbooks.Open("C:\Folder\Folder\File.xls) ExApp.Visible = True ExWbk.Application.Run "ModuleName.YourMacro" ExWbk.Close SaveChanges:=True
If you want to run this macro in the background and not open a visible instance of Excel, then set ExApp.Visible to False.
这篇关于如何从Outlook宏运行Excel宏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文