我有一个访问2007数据库,我需要在表单上创建一个按钮,当我点击它时,它将在另一个办公应用程序上运行一个宏,如visio和ms项目
以下链接显示了如何将其用于word和excel等其他应用程序,但它没有显示如何在visio或ms项目应用程序中使用它
https://support.microsoft.com/en-us/kb/177760
运行现有Microsoft Excel宏的子过程
以下Sub过程假定工作簿ExcelFile.xls包含一个名为" TestMacro的宏。"
Sub XLTest()
Dim XL as Object
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open "C:\My Documents\ExcelFile.xls"
' If there is more than one macro called TestMacro,
' the module name would be required as in
'
' XL.Run "Module1.TestMacro"
'
' to differentiate which routine is being called.
'
XL.Run "TestMacro"
End Sub
运行现有Microsoft PowerPoint宏的子过程
以下Sub过程假设演示文稿PPTAutomation.ppt包含一个名为" AutomationTest的宏。"
Sub PPTTest()
Dim PPT as Object
Set PPT = CreateObject("PowerPoint.Application")
PPT.Presentations.Open "C:\My Documents\PPTAutomation.ppt", , ,False
' Note that the file name and the module
' name are required to path the macro correctly.
PPT.Run "PPTAutomation.ppt!Module1.AutomationTest"
End Sub
运行现有Microsoft Word宏的子过程
以下Sub过程假定WordDoc.Doc文档包含一个名为" WordMacro的宏。"
Sub WDTest()
Dim WD as Object
Set WD = CreateObject("Word.Application")
WD.Documents.Open "C:\My Documents\WordDoc.Doc"
' Note that the project name and module name are required to
' path the macro correctly.
WD.Run "Project.Module1.WordMacro"
End Sub
有什么建议吗?
答案 0 :(得分:1)
Visio:
Sub VISTest()
Dim VIS as Object
Set VIS= CreateObject("Visio.Application")
VIS.Documents.Open "PATH"
' Note that the project name and module name are required to
' path the macro correctly.
VIS.Run "MARCRONAME"
End Sub
<强>项目:强>
我无法测试项目,没有测试,但请看https://msdn.microsoft.com/en-us/library/bb223292%28v=office.12%29.aspx说
Dim pj As Object
Set pj = CreateObject("MSProject.Project")
pj.Application.FileOpen "My Project.mpp"
小心在Office-Applications
的信任中心启用宏