Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ms Access Execute Function
#1
Hello
I would like to connect an open MS Access File to execute a Function.

Someting like this in VB(A) Script:

Dim oApp As Access.Application

Set oApp = GetObject("C:\Folder\File.accdb")
Debug.Print oApp.Run("QM_Test", 123)


I tried this:


typelib MsAcc "C:\Programme\Microsoft Office\Office12\MSACC.OLB"

MsAcc.Application oApp
oApp = GetObject("C:\Folder\File.accdb") (Error: expected 3 to 3 arguments, not 1.)
VARIANT* f = &oApp.Run("QM_Test", 123) (Error: expected VARIANT* tip: use operator & to get address of variable, or operator + to cast type.)


Help is welcome. Thanks
#2
This also dosn't work:

typelib MsAcc "C:\Programme\Microsoft Office\Office12\MSACC.OLB"
typelib VBA "C:\Programme\Gemeinsame Dateien\Microsoft Shared\VBA\VBA6\VBE6.DLL"
VARIANT x = "F:\Folder\File.accdb"
VARIANT v = "Access.Application"
VARIANT z

MsAcc.Application oApp
oApp = VBA.GetObject(&x &v) Exception 0xC0000005. Access violation. Cannot read memory at 0x0. In at 0x0 (0x0+0x0).
z = oApp.Run("QM_Text", 123)


By using VBA I always get errors with functions.
Is there any way to get a Pointer to a open MS Access Application?
Thanks
#3
Menu Tools -> COM libraries,
find Microsoft Access ... Library,
double click it,
Close.

Macro Macro2769
Code:
Copy      Help
typelib Access {4AFFC9A0-5F99-101B-AF4E-00AA003F0F07} 9.0
Compile the macro.
Type Access, dot, and select Application from list. Declare a variable.
Call its member function _getactive. Or _getfile, but it probably creates new hidden msaccess process.

If Quick Macros is running as Administrator or uiAccess, let the macro run in separate process as user.

Whole macro
Macro Macro2769
Code:
Copy      Help
;/exe 1
typelib Access {4AFFC9A0-5F99-101B-AF4E-00AA003F0F07} 9.0
Access.Application oApp._getactive
VARIANT v1=123 ;;need a variable because QM cannot pass constant values to ByRef parameters
oApp.Run("QM_Test" v1)

;BEGIN PROJECT
;flags  6
;END PROJECT
#4
Thanks it works.

I have just detected that i chan choose the instance with oApp._getfile.


Forum Jump:


Users browsing this thread: 1 Guest(s)