VBA timetrack

I am trying to create a Time tracking VBA script. I have used the microstation book "Learning Microstation VBA". I can get the script to write to a text document and append on the end to keep track of file opening and closing. This can become a VERY large document that is nightmare to read. This is a sample of the code to initialize:

Private Sub Class_Initialize()
   Dim FFile As Long
    FFile = FreeFile
   Open "\time\Time.txt" For Append As #FFile
              Print #FFile, "INIT" & vbTab & Now
       Close #FFile
     Set MSApp = Application
End Sub

I would like to have the data of the opening and closing saved in either an excel or CSV file so it can be represented in a graph and used in presentations.

When I change the file type to either, xls, xlsx nothing happens.

When I change the file type to CSV I just get alot of random code generated in the file.

 

Does anyone know how to represent the time taken to work on a DGN file in a usable format?

Thank you

  • Hi there,

    You should be able to open up the text file in excel and define the file as tab delimeted. Depending on your version of excel it should bring up the text import wizard, where you can define how you want to break up your data.

    For the CSV option to work, you will need to modfiy your PRINT statement to read "INIT," & Now    as the delimeter in CSV is the comma ( As in Comma Separated Values)

    HTH

     Andy

  • samk:

    I would like to have the data of the opening and closing saved in either an Excel or CSV file so it can be represented in a graph and used in presentations.

    Excel up to Excel 2003 uses the BIFF8 format in binary xls files. Excel 2007 uses XML format in xlsx. You could write code to create BIFF8 or xlsx, but it will be hard work. You're best sticking to CSV, which Excel is quite happy with.

    samk:

    When I change the file type to either xls or xlsx nothing happens.

    You might be able to do that with a magic wand. Unfortunately, simply changing a file extension does not auto-magically reformat the file contents. If only computer life were that simple.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • Fizzer21

    I tried the changes and now it works exactly like I hoped. I can visually display the data in a nice readable, presentable format.

    Thank you

  • Jon,

    I was unaware that 2007 uses XML instead of BIFF8, since I dont have a magic wand, I was hoping that the backwards conversion of excel (2007 reading 2003) would suffice. However, since this is not the case, rather than create extra work for myself for little results, ill stick the CSV. Thanks for clarifying.