在 SSIS 包中执行 Access 2003 宏






2.33/5 (2投票s)
2006年12月29日

57167
在 SSIS 包中执行 Access 2003 宏。如何在 SSIS 包中调用 Access 宏
注意:更改 Access 宏的安全级别,否则每次 SSIS 包
执行时,都会弹出安全警告消息。为了避免这种情况,请按照以下说明操作
打开 Access --> 工具 --> 宏 --> 安全
点击“安全”并将级别更改为“低”。
引言
基本上,要在 SSIS 包中执行 Access 宏,我们需要从 Office XP PIA 下载 Microsoft.Office.Interop.Access DLL。该文件可以从本文顶部的链接下载。
使用代码
- 从 Oxppia.exe 中提取 Microsoft.Office.Interop.Access DLL
- 将 Microsoft.Office.Interop.Access DLL 拖放到全局程序集目录 (GAC)
- Windows 2000 的 C:\WINNT\assembly
- Windows XP 和 Windows 2003 的 C:\WINDOWS\assembly
- 将 Microsoft.Office.Interop.Access 复制粘贴到
- Windows 2000 的 C:\WINNT\Microsoft.NET\Framework\v2.0.50727
- Windows XP 和 Windows 2003 的 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
- 在脚本任务中添加 DLL 引用
- 添加以下代码
- 在 SSIS 中创建一个新项目
- 拖放脚本任务
- 将代码复制粘贴到脚本任务编辑器中
Imports Microsoft.Office.Interop.Access
Try
Dim objAccess As New Access.Application
objAccess.OpenCurrentDatabase("D:\TestMacro.mdb", False)
' Add the Access File Path
objAccess.DoCmd.RunMacro("Macro1")
' Replace Macro1 with the name of your macro
objAccess.CloseCurrentDatabase()
objAccess.Quit(Access.AcQuitOption.acQuitSaveNone)
objAccess = Nothing
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString())
End Try
Dts.TaskResult = Dts.Results.Success