Microsoft Access & Win32::Ole
am 29.10.2005 01:03:26 von BartlebyScrivener
I have a database called Quotations2005 which I can open with the
following. I would also like to run some event code contained in the
switchboard form. The code is contained in Private Sub
Command23_Click()
Is this even possible? Does one use the Run Macro Command as in Word?
use strict;
use warnings;
use Win32::OLE;
my $access = CreateObject Win32::OLE 'Access.Application' || die
"Cannot create Access object\n$!\n";
$access -> {'Visible'} = 1;
$access -> OpenCurrentDatabase('d:\Access
Databases\Quotations2005.mdb');
# Here's the scary part
$access -> DoCmd -> RunMacro(Form_Switchboard.Command23_Click);
$access->Quit();
Thank you for any help.
Re: Microsoft Access & Win32::Ole
am 29.10.2005 16:50:36 von BartlebyScrivener
Apologies to all. I'm answering myself to prevent anyone from doing
unnecessary work. I found the answer at:
ACC: Using Microsoft Access as an Automation Server
http://support.microsoft.com/?id=147816
Calling Custom Procedures
In your Automation code, you can call a custom Visual Basic procedure
stored in a Microsoft Access database by using the Run method of the
Application object. The custom procedure must be declared as Public
and located in a standard module (not a form or report module). For
example, to run MyDateAdd function, add the following sample code to
your Automation Controller:
# Dim objAccess as Object, newdate as Date
# Set objAccess = GetObject _
# ("C:\Program Files\Microsoft
Office\Office\Samples\Northwind.mdb")
# newdate = objAccess.Run("MyDateAdd", "m", 1, Date)
# MsgBox newdate,,"MyDateAdd returned"