调用进程在访问模块从

调用进程在访问模块从

本文介绍了调用进程在访问模块从.net?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有从净麻烦自动化Access 2007年,无论是VB或C#。所有我想要做的就是调用子程序从.NET中访问模块。

最后,我要让它在VB的工作,但我一直在用相同的结果试图两者。

下面是code在我的VB的测试形式。它导致错误:

System.Runtime.InteropServices.COMException(0x800A9D9F):从HRESULT异常:0x800A9D9F在Microsoft.Office.Interop.Access.ApplicationClass.Run(字符串程序,对象和放大器;的Arg1,对象和放大器; ARG2,...,对象和放大器; Arg30)

在访问我的测试小组被命名为MyTest的,并命名为模块1的模块。它所做的就是在一个表中插入一条记录。它运行良好,从内部访问。我曾尝试Module1.MyTest,MyTest的(),叫MyTest的,等等,没有运气。

的各种排列

我发现在网络上自动访问(和其他Office应用程序)的一些其他的例子,但似乎无法得到任何工作。如果任何人都可以指向我一个工作的例子,我将不胜感激。

样品code:

 进口访问= Microsoft.Office.Interop.Access
进口Microsoft.Office.Core

公共类FormTest
    私人小组cmdTest_Click(BYVAL发件人为System.Object的,BYVALË作为System.EventArgs)把手cmdTest.Click

        昏暗AA作为新Access.Application()

        尝试
            aa.OpenCurrentDatabase(C:\ Test.accdb)
            aa.Run(MyTest的)
        抓住EX为例外
            MSGBOX(ex.ToString())
        最后
            如果AA状态并没有任何然后
                aa.Quit(Access.AcQuitOption.acQuitSaveNone)
            结束如果
            Me.Close()
        结束尝试

    结束小组
末级
 

解决方案

这是安全的。在Access中,我不得不关闭所有的安全检查。一旦我这样做,它工作得很好。

I am having trouble automating Access 2007 from .Net, either VB or C#. All I want to do is call a subroutine in an Access module from .Net.

Ultimately, I have to make it work in VB, but I've been trying both with the same results.

Below is the code in my VB test form. It results in the error:

System.Runtime.InteropServices.COMException (0x800A9D9F): Exception from HRESULT: 0x800A9D9F at Microsoft.Office.Interop.Access.ApplicationClass.Run(String Procedure, Object& Arg1, Object &Arg2, ..., Object &Arg30)

My test Sub in Access is named "MyTest" and is module named "Module1". All it does is insert a single record in a table. It runs fine from within Access. I have tried various permutations of "Module1.MyTest", "MyTest()", "Call MyTest", etc., with no luck.

I have found some other examples on the net of automating Access (and other Office applications) but can't seem to get any to work. If anyone could point me to a working example I would be grateful.

Sample code:

Imports Access = Microsoft.Office.Interop.Access
Imports Microsoft.Office.Core

Public Class FormTest
    Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click

        Dim aa As New Access.Application()

        Try
            aa.OpenCurrentDatabase("c:\Test.accdb")
            aa.Run("MyTest")
        Catch ex As Exception
            MsgBox(ex.ToString())
        Finally
            If aa IsNot Nothing Then
                aa.Quit(Access.AcQuitOption.acQuitSaveNone)
            End If
            Me.Close()
        End Try

    End Sub
End Class
解决方案

It was security. In Access, I had to turn off all security checking. Once I did that, it worked fine.

这篇关于调用进程在访问模块从.net?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 08:55