Consulting

Results 1 to 14 of 14

Thread: Solved: Track File Usage

  1. #1

    Solved: Track File Usage

    I thought this would be easy but it has been more challenging for me that I believed.
    Since I am not an administrator on my network, I do not have the tools available to me to track a file, to see who has used the file, or to see who has it open. Yes, there are ways to look at the owner at the current time but that doesn't tell who has been in the file.


    1. Create User defined text file on network (start the user on the same place on the network every time) to collect data
    2. Enter full path and file name of file tracked in new text file
    3. Add code to 'Workbook Open' to 'append' to text file' Environ("Username") and date - "Opened"
    4. Add code to 'Workbook BeforeClose' to 'append' to text file' Environ("Username") and date - "Saved"

    I think the adding code to the current file will be the easy part but I could not figure out how to create a user defined text file on the network.

    Any advice would be helpful.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Why not just add a sheet to the workbook, and hide it.

  3. #3
    Quote Originally Posted by xld
    Why not just add a sheet to the workbook, and hide it.
    There are three main problems with and internal tracking:
    1. That is an idea but some files are partially-protected via code. Some users have full access to the files but others have 'read-only' rights. I'd like to track both users. To track both users, the code would have to change the status of the file, add the information, then close the file.
    2.If the file is not saved after each use, then the data is not maintained. The code would force the file to save thus changing the properties of the file. Then it would be difficult to track who just opened the file to view it and the ones who opened and saved.
    3. If the data is held within the file, each time a user opened the file it would be 'modified' thus making it impossible search the files based upon 'last modified'.

  4. #4
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    For the desperate ones. Maybe you can do something with this. Change the path to the logging file to a path that everyone can acces on the network. You can make the file hidden so users can't see it.

    Charlize

    ps.: Logfile will now be created in same directory as the workbook. Is called the same as the workbook exept .txt as extension.

  5. #5
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Well, MrRhodes2004, was this a suitable solution to start with ?

    Charlize

  6. #6
    VBAX Regular xls's Avatar
    Joined
    Aug 2005
    Posts
    76
    Location
    Really good
    Winners dont do different things, they do things differently.

  7. #7
    VBAX Mentor jammer6_9's Avatar
    Joined
    Apr 2007
    Location
    Saudi Arabia
    Posts
    318
    Location
    What a ... It's just happen that I need that code also...
    T-ogether
    E-veryone
    A-chieves
    M-ore


    One who asks a question is a fool for five minutes; one who does not ask a question remains a fool forever.

  8. #8
    Quote Originally Posted by Charlize
    Well, MrRhodes2004, was this a suitable solution to start with ?

    Charlize
    It gave my some ideas but it didn't solve the problem.

    I'd like to be able to run the macro which would open a dialog box which would allow the user to select a folder that they want their tracking text file to be stored then it would ask them for the name of the file. Once it had that information, it would create that file.

    Any ideas?

  9. #9
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Quote Originally Posted by MrRhodes2004
    It gave my some ideas but it didn't solve the problem.

    I'd like to be able to run the macro which would open a dialog box which would allow the user to select a folder that they want their tracking text file to be stored then it would ask them for the name of the file. Once it had that information, it would create that file.

    Any ideas?
    I don't get this. You want that the user of a file knows that everything the user does, is tracked in an external file. Most users don't like it that someone else can see how they messed up a file and what they have done during the use of a file.

    Charlize

  10. #10
    Typically, the file creator or author would create the tracker code and text file. Once the tracker has been issued, each time the file is opened or saved by other users, a comment would be placed into the text file. This would be done automatically. In a company environment, all movements within the system are prevue to the company including opening, changing, and messing up others files. Therefore, I have no concern with what the user likes or does not like.
    Plus, the intent is not track who messed up the file. It is more of an exercise to see who is using the file and when. It will also be helpful to find out who is currently in it since our system is not always helpful. It will sometimes state, when another is in the file and another attempts to open it, 'The file is locked for editing by "Company Name".' This does not help me identify who has the file currently open.
    Last edited by MrRhodes2004; 04-20-2007 at 08:33 AM.

  11. #11
    [VBA]Sub CreateAfile()
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.CreateTextFile("c:\testfile.txt", True)
    f.WriteLine ("This is a test.")
    f.Close
    End Sub[/VBA]

    I can use VBA to Create a text file via the manner above. But the problem is that I dictate the location and file name in the code. Is there a way to have the user define the folder and file name with a dialog box?

  12. #12
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Was there ever a solution to the treeview thread some time back, where the user simply selects the file from the graphical listing of the file?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  13. #13
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Did a search on treeview and theres a number of threads including this one from Ken Puls

    http://vbaexpress.com/forum/showthre...light=treeview

    Would this be helpful?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  14. #14
    [VBA]
    Sub CreateAfile()
    Dim vntSaveName As Variant

    vntSaveName = application.GetSaveAsFilename
    If vntSaveName = "False" Then exit Sub

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.CreateTextFile(vntSaveName, True)
    f.WriteLine ("This is a test.")
    f.Close
    End Sub
    [/VBA]

    http://www.vbaexpress.com/forum/showthread.php?t=12434

    I think I have what I need. Thanks everyone.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •