7 Replies Latest reply: May 15, 2014 10:01 AM by rconverse _ RSS

    Windows Scheduler

    rconverse _

      Hello,

       

      I have a VB script that I use to launch an MS Access routine through windows scheduler.

       

      dim accessApp

      on error resume next

      set accessApp = CreateObject("Access.Application")

      accessApp.OpenCurrentDataBase("F:\OpenAccess\croy\Access\Lagasse_Reports.mdb")

      accessApp.Run "Excess_PO"

      accessApp.Quit

      set accessApp = nothing

      /code

       

      I was wondering if it would be possible to apply the same mentality to a Monarch report.  Has anyone attempted this?  Here is what I have so far:

       

      Dim strLog As String

      Dim strExpTable As String

      Dim strModel As String

      Dim blnCreated As Boolean

      Dim strReport as string

      Dim strModelName as string

      Dim strPath as string

      Dim strExportTable as string

       

      strReport = "F:\OpenAccess\Daily Inventory\InventoryDetail.txt"

      strModelName = "Buyer_Inventory.xmod"

      strPath = "F:\OpenAccess\Daily Inventory\"

      strExportTable = "Daily Inventory.mdb"

      strModel = "F:\OpenAccess\croy\Monarch Queries\" & strModelName

      strExpTable = strPath & strExportTable

      strLog = strPath & "Log.log"

       

      Dim MonarchObj As Object

      Dim openfile, openmod, t As Boolean

      'If Monarch is currently active GetObject will use Monarch. If it is not use the CreateObject() to

      'open another copy of Monarch.

       

      Set MonarchObj = GetObject("", "Monarch32")

       

      If Err.Number <> 0 Then

       

           blnCreated = True

           Set MonarchObj = CreateObject("Monarch32")

       

      End If

       

      t = MonarchObj.SetLogFile(strLog, False)

      openfile = MonarchObj.SetReportFile(strReport, False)

      If openfile = False Then

          openmod = MonarchObj.SetModelFile(strModel)

          If openmod = True Then

              With MonarchObj

                 .ExportTable (strExpTable)

              End With

          End If

          Else: openfile = True

              openmod = MonarchObj.SetModelFile(strModel)

              If openmod = True Then

                  With MonarchObj

                     .ExportTable (strExpTable)

                  End With

              End If

          End If

               

      MonarchObj.CloseAllDocuments

      MonarchObj.Exit

      /code

       

      Thanks in advance for any assistance.

       

      Roger

        • Windows Scheduler
          Nick Osdale-Popa

          Just scanning the code I see no reason why it won't work.

           

          Just note, that if you're using a VBScript (.vbs) file, that it doesn't support defined datatypes, thus you will need to remove all the AS  info and just DIM the variables as variant.

            • Windows Scheduler
              rconverse _

              Just scanning the code I see no reason why it won't work.

               

              Just note, that if you're using a VBScript (.vbs) file, that it doesn't support defined datatypes, thus you will need to remove all the AS  info and just DIM the variables as variant.[/QUOTE]

               

              I am, thanks!  It was erroring on the first line and couldn't figure out why.  I'm new to straight vbscripting, so a small detail like this can send me in a loop for hours.

               

              Thanks a ton!  This site is great.

               

              Thank again,

              Roger