2 Replies Latest reply: May 15, 2014 9:56 AM by Steve_P _ RSS

    Project File Manipulation

    Steve_P _

      Hello!  I would like to have a project file that opens up a file from a specific folder, but part of the filename (a mmdd formatted date) changes daily.  Is there some way to put a wildcard into the code?  Here is what I currently have for the project file:

       

      [font="courier"] 

      MFWPRJ01

      C:ATBO015_0725_CADean.rtf

      C:ATBC015_0725_CADean.rtf

      C:ATBA015_0725_CADean.rtf

      C:Program FilesMonarchModelsATB_Detail.mod

      fc

      CADEANWEEK

      Steve Page

      [/font][/quote]Any suggestions?  I have already tried replacing the 0725 with ???? and ****, but they both come up with errors when I try to run the project.

       

      Am I coming at this from the completely wrong angle?  Please let me know what you think.  (BTW I'm still on v5.02, working on getting my boss to approve the upgrade - wish me luck!)

       

      Thanks!  Steve

        • Project File Manipulation
          Data Kruncher

          Steve,

          My solution to your changing report name problem involves dynamically recreating the project file each day. I'm assuming that you want to run the project on the same day as the report files are created. The program could be easily changed to create a project file for reports generated on a certain date, specified when you run the program. Anyway, I'm getting ahead of myself.

           

          Run Notepad and copy and paste into it the following code:

          [font="courier"]dim strday

          dim strmonth

          dim rpt1

          dim rpt2

          dim rpt3

           

          if day(date) < 10 then

             strday="0" & day(date)

          else

             strday=day(date)

          end if

           

          if month(date) < 10 then

             strmonth="0" & month(date)

          else

             strmonth=month(date)

          end if

           

          rpt1 = "C:ATBO015_" & strmonth & strday & "_CADean.rtf"

          rpt2 = "C:ATBC015_" & strmonth & strday & "_CADean.rtf"

          rpt3 = "C:ATBA015_" & strmonth & strday & "_CADean.rtf"

           

          Set fs = CreateObject("Scripting.FileSystemObject")

          Set a = fs.CreateTextFile("C:Daily.prj", True)

          a.WriteLine("MFWPRJ01")

          a.WriteLine("[InputFile]")

          a.WriteLine(rpt1)

          a.WriteLine("[InputFile]")

          a.WriteLine(rpt2)

          a.WriteLine("[InputFile]")

          a.WriteLine(rpt3)

          a.WriteLine("[ModelFile]")

          a.WriteLine("C:Program FilesMonarchModelsATB_Detail.mod")

          a.WriteLine("[Sort]")

          a.WriteLine("fc")

          a.WriteLine("[Summary]")

          a.WriteLine("CADEANWEEK")

          a.WriteLine("[ViewSummary]")

          a.WriteLine("[SummaryNoChart]")

          a.WriteLine("[Author]Steve Page")

          a.WriteLine("[Description]")

          a.WriteLine("[ASCII]")

          a.WriteLine("[END]")

          a.Close

            /font[/quote]Save this to your desktop as "Make Project File.vbs". Double click this new icon to execute it. Now create a new shortcut on your desktop which points to the C:Daily.prj file.

           

          Now you'll just need to run the .vbs each day to update the project file, then run the project.

           

          Hope this helps,

          Kruncher

          • Project File Manipulation
            Steve_P _

            This looks great!  I have been pulled off to a different project this afternoon, but I am anxious to try this programming.

             

            Thank you!