Microsoft Access & Win32::Ole

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

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 -> = 1;
$access -> OpenCurrentDatabase('d:\Access

# Here's the scary part

$access -> DoCmd -> RunMacro(Form_Switchboard.Command23_Click);

Thank you for any help.

Re: Microsoft Access & Win32::Ole

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

 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
#   newdate = objAccess.Run("MyDateAdd", "m", 1, Date)
#   MsgBox newdate,,"MyDateAdd returned"

Site Timeline