Open MS Access and Fire Macro using MS Outlook

I have done some research, and I think the best way to automatically run a macro is to use the AutoExec method in Access.

I believe the script below will do the job.

Option Compare Database

'------------------------------------------------------------
' AutoExec
'
'------------------------------------------------------------
Function AutoExec()
On Error GoTo AutoExec_Err

    DoCmd.RunCommand acCmdWindowHide
    MsgBox "Welcome to the client billing application!", vbOKOnly, "Welcome"
    DoCmd.OpenTable "Orders", acViewNormal, acEdit


AutoExec_Exit:
    Exit Function

AutoExec_Err:
    MsgBox Error$
    Resume AutoExec_Exit

End Function

Now my question is the best way to trigger an access database opening event? Unfortunately, the Windows Task Scheduler is disabled by my IT department (he must love it).

I think there should be a way to get Outlook to open the access database as a task or something similar. I experimented with several ideas, but couldn't work anything.

Does anyone know how to do this?

To add a little more color to this, basically I want to automatically import data from a remote SQL Server database into Access. As you might have guessed, SQL Server Agent is also disabled.

, Outlook, , .

+1
2

Windows, , , ( - - .. ).

...

Outlook VBA , . Access.

:

  • Outlook. , , .
  • Access Outlook .
  • . , .

ThisOutlookSession Outlook VBA IDE:

Private WithEvents m_reminders As Outlook.Reminders

Private Sub Application_Startup()
    Set m_reminders = Application.Reminders
End Sub

Private Sub m_reminders_BeforeReminderShow(Cancel As Boolean)
    Dim reminderObj As Reminder
    For Each reminderObj In m_reminders
        If reminderObj.Caption = "MyDailyAccessImport" Then
            Dim accessApp As Object
            Set accessApp = CreateObject("Access.Application")
            accessApp.Visible = True
            accessApp.OpenCurrentDatabase "C:\Foo\MyDatabase.accdb"
            Cancel = True
            Exit For
        End If
    Next
End Sub

AutoExec, .

+1

-:
 - Microsoft TechNet: Windows

... , I.T. : >
 - Slashdot: -

... :
 - : -


[ ] , Q & A, : " SMS".

(?) . , : " I.T."...


, , , , , , , , , " " ", "...

... 𝘣𝘶𝘵 𝘤𝘢𝘯 𝘺𝘰𝘶 𝘦𝘹𝘱𝘭𝘢𝘪𝘯 𝘞𝘏𝘠 𝘐 𝘮 𝘰𝘯𝘭𝘺 𝘢𝘭𝘭𝘰𝘸𝘦𝘥 𝘵𝘰 𝘩𝘢𝘷𝘦 𝘜𝘚𝘉 𝘴𝘭𝘰𝘵 𝘦𝘯𝘢𝘣𝘭𝘦𝘥? "

, , , , , "".

IT vs IT


Access

, Access:

  • AutoExec : RunCode. . - , VBA.

    AutoExec

    , Function ( a Sub), . ( )

  • > > , Form_Open . ( )

  • , Timer . , Access , Excel, ( ) . ( .)

  • /X: Access, . , .BAT :

    C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE /x:myMacro

  • /CMD: Access . VBA , , COMMAND. :

    :

    MSACCESS.EXE /cmd:Take actions one and two

    VBA:

    If InStr(Command,"two") <> 0 Then
    'do action two
    End if

, , /CMD .

Office COMMAND .

... , ( ), , , . , - , , .

monitored


Outlook

Run a Script, Outlook VBA, , , . Outlook script.

, , , .

, :

*** " X, , :

( " ", !)


:

IT at work

+2

Source: https://habr.com/ru/post/1695328/


All Articles