8 Replies Latest reply: May 15, 2014 9:55 AM by Gareth Horton RSS

    Openning files via VB (SetReportFile)

    DY*BIM _

      I am trying to write a script that will open a set of reports in a specific folder.  The report names are slightly different from each other and they will change daily.  The first 2-3 characters (depends on the report, there are 3 groups) are the same (PCC123, PCC456, etc.)

       

      I tried to script with

      openfile = objMonarch.SetReportFile("D:Program FilesMonarchReportsCR*", False) but it doesn’t work.

       

      I am using Monarch 7.01 Pro.

       

      Any advise?

       

      Thanks,

       

      dy

        • Openning files via VB (SetReportFile)
          Nick Osdale-Popa

          Untested:

          [font="courier"]strFile = Dir("D:Program FilesMonarchReportsCR*")

          Do while strFile <> ""

              openfile = objMonarch.SetReportFile(strFile, True)

              If OpenFile = False Then

                  MsgBox "Error Opening File: " & strFile

                  Exit Sub

              End If

              strFile = Dir()

          Loop[/font][/quote]objMonarch.SetReportFile(strFile, True[/b]) tells Monarch to retain the reports rather than only keeping one report open.

           

          [size="1"][ June 25, 2004, 02:59 PM: Message edited by: Nick Osdale-Popa ][/size]

          • Openning files via VB (SetReportFile)
            DY*BIM _

            Tried it, didn’t work...at least it recognized the first file when it gave me the error message.

             

            Here is the code I am using…any advise will be helpful

             

            Thanks

             

            dy

             

             

            Private Sub Form_Load()

             

                Dim objMonarch As Object

                Dim blnOpenFile As Boolean

                Dim blnOpenMod As Boolean

                Dim blnLog As Boolean

                Dim strFile As String

                 

             

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

                 

                If objMonarch Is Nothing Then

                    Set objMonarch = CreateObject("Monarch32")

                End If

             

                'Set log file

                blnLog = objMonarch.SetLogFile("D:MCR.log", True)

                 

                 

                strFile = Dir("D:Program FilesMonarchReportsCRCR*")

                Do While strFile <> ""

                    openfile = objMonarch.SetReportFile(strFile, True)

                    If openfile = False Then

                        MsgBox "Error Opening File: " & strFile

                        Exit Sub

                    End If

                    strFile = Dir()

                Loop

             

                If openfile = True Then

                    openmod = objMonarch.SetModelFile("I:ModelsClaimRun.mod")

                    If openmod = True Then

                         objMonarch.ExportTable ("D:Program FilesMonarchExportClaimRun.xls")

                    End If

                End If

                 

                objMonarch.CloseAllDocuments

                objMonarch.Exit

            End Sub

            • Openning files via VB (SetReportFile)
              RalphB _

              I tried the code you posted and saw the strFile line was returning only the file name, not the path and file name.  The complete path and file name is necessary in the openfile command line.

               

               

              Instead of:

               

              strFile = Dir("D:Program FilesMonarchReportsCRCR*")

              Do While strFile <> ""

              openfile = objMonarch.SetReportFile(strFile, True)

               

               

              Try

               

              strPath = "D:Program FilesMonarchReportsCR"

              stFile = Dir(strpath & "cr*")

              Do Whle strFile <>""

              openfile = objMonarch.SetReportfile(strPath & strFile, True)

               

               

              Hope this helps you out.

               

              Ralph

              • Openning files via VB (SetReportFile)
                DY*BIM _

                Thank you! it worked...

                 

                Now I am running into a second obsticle:

                 

                When trying to use JetExportTable, I get the following error message:

                 

                Compile Error:

                Expected : =

                 

                The code reads:

                 

                objMonarch.JetExportTable ("D:ProgramsMonarchExportClaims.mdb", "Epic", 0)

                 

                For a second file set I will also have:

                objMonarch.JetExportTable ("D:ProgramsMonarchExportClaims.mdb", "Vendors", 2)

                 

                Should I expect similar compiling problems?

                 

                Help...

                • Openning files via VB (SetReportFile)
                  Nick Osdale-Popa

                  objMonarch.JetExportTable just as objMonarch.SetReportFile will return a boolean of whether or not it was successfull.  You should set a variable to objMonarch.JetExportTable to determine if it successfully exported:

                   

                  retval = objMonarch.JetExportTable(~)

                  • Openning files via VB (SetReportFile)
                    DY*BIM _

                    Thank you...works like a charm!

                    • Openning files via VB (SetReportFile)
                      aardvark _

                      Do all Monarch methods return a boolean value of whether they were successful, or just certain ones?

                      • Openning files via VB (SetReportFile)
                        Gareth Horton

                        Hi

                         

                        Here is a list of the methods that return a boolean based on success:

                         

                        ExportSummary

                        ExportTable

                        FindText

                        JetExportSummary

                        JetExportTable

                        OpenDatabase

                        PRFPublish

                        SetLogFile

                        SetModelFile

                        SetPRFFile

                        SetProjectFile

                        SetReportFile

                         

                        Originally posted by aardvark:

                        Do all Monarch methods return a boolean value of whether they were successful, or just certain ones? /b[/quote]