5 Replies Latest reply: May 15, 2014 9:56 AM by Data Kruncher RSS

    Exporting a filter automatically

    aglatfelter _

      I have a report that I use a bunch of different filters on.  For the sake of argument lets say I have filters A, B, and C.  I also have folders X, Y, and Z.  Can I export the data from filter A to folder X, the data from filter B to folder Y, and the data from filter C to folder Z automatically?  I currently use Monarch v5, and I have not found a way to do it.  Does v6 or v7 have that capability?  Does v5 have it and I just havent figured it out correctly?  Any help would be appreciated.  Thanks in advance.

        • Exporting a filter automatically
          Bruce _

          Version 5 did not have, but version 7 certainly can do what you want. I export many differnt reports and summaries to many differnt files and directories with no problem.



          • Exporting a filter automatically
            Data Kruncher

            aglatfelter and Bruce,


            I have developed a solution for you using VB script, which I've tested successfully with one of my existing project files. I also use V5.


            The first part of the code creates an array (basically a lookup table) which defines which filter name to use for which export folder.


            Then it opens the project file and loops through the array, exporting each filter. Finally it properly shuts down Monarch.


            [font="courier"]dim arfilters(3,2)

            dim counter


            arfilters(1,1)="Filter One"

            arfilters(1,2)="C:Folder X"

            arfilters(2,1)="Filter Two"

            arfilters(2,2)="C:Folder Y"

            arfilters(3,1)="Filter Three"

            arfilters(3,2)="C:Folder Z"


            Set MonarchObj = CreateObject("Monarch32")


            openfile = MonarchObj.SetLogFile("c:monarch eportsVBS.LOG",False)

            openfile = MonarchObj.SetProjectFile("C:My Project FilesMy Filtered Project.prj")


            for counter = 1 to 3


                 MonarchObj.CurrentFilter = arfilters(counter,1)


                 If openfile Then

                      MonarchObj.ExportTable(arfilters(counter,2) & "Filtered export.xls")

                 end if






            Set Monarchobj = Nothing[/font][/quote]Just copy this code into Notepad, edit the filters and folder names, and the .xls file name too, and save it with a name like "Export Filters.vbs". If you type the quote marks around the name, Notepad won't give the file a .txt extension. Save it to your desktop and you can just double click the icon to run it.


            Hope this helps. Let us know how you make out.




            • Exporting a filter automatically
              aglatfelter _



              I just did a little test run and everything seemed to work.     


              I did get an error in the script, however.


              Line 19

              Char 1

              Error: Object doesnt support this property or method

              Code 800A01B6

              Source Microsoft VBScript runtime error.


              The good news is that the files were created in their respective folders, so the error doesnt really seem to matter.


              Thank you so much!

              • Exporting a filter automatically
                aglatfelter _



                I have a quick question about adding to that code.  If I have N number of things that each needed to be exported to its own folder, do I just change the code to


                dim arfiters(N,2)


                arfilters(N,1)="Filter One"

                arfilters(N,2)="C:Folder X"


                for counter = 1 to N




                • Exporting a filter automatically
                  Data Kruncher



                  That is correct. Think of the array as (Rows, Columns) so that it builds a little lookup table, where you need one row for each filter item.


                  The name of the filter goes in the first column, and the name of the destination folder that you want to use for that filter goes in the second column.


                  Then, since we cannot pass a filter name as a command line parameter, we can take advantage of the object model instead by using a script.


                  Glad to here that this worked well for you. Odd about that script error - I'm not able to duplicate it.