Results 1 to 3 of 3

Thread: Need to invoke sub in VBAProject.OTM from VBScript

  1. #1

    Thread Starter
    Addicted Member New2VB's Avatar
    Join Date
    Jun 2000
    Los Angeles

    Question Need to invoke sub in VBAProject.OTM from VBScript

    I have a custom Outlook form that needs to pull data from my Outlook database generally to populate itself and, launch additional forms, depending on the data that comes back. I've written the subroutines that do all the work in VBA and those now reside in the Outlook Macro file (VBAProject.OTM). I want to be able to invoke the triggering code from within the custom form by clicking on a Command Button on the form. It is my understanding that the only place in which I can write my event handler for the Command Button is in the VB Scripting window available through the "View Code" menu item when in Form Design Mode in Outlook's Developer tab.

    I need the syntax for calling subroutines or functions in the VBAProject.OTM from the form's VBScript window.

    I appreciate the guidance.

  2. #2
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Idaho Falls, Idaho USA

    Re: Need to invoke sub in VBAProject.OTM from VBScript

  3. #3
    Join Date
    Dec 2004

    Re: Need to invoke sub in VBAProject.OTM from VBScript

    i have not tested, but you could set up a reminder item by code from vbs, which can fire the application_reminder event, from where you can call whatever other procedures you want, including to delete the item when finished

    Set app = CreateoObject("Outlook.Application")
    Set t = app.CreateItem(3)
    t.ReminderOverrideDefault = True
    t.ReminderTime = Now + TimeSerial(0, 0, 1)
    t.ReminderSet = True
    t.subject = "temp"
    Private Sub Application_Reminder(ByVal item As Object)
    MsgBox "Yes3"   ' do whatever
    End Sub
    partially tested
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width