Text file monitoring

mtheriault

Board Regular
Joined
Sep 16, 2008
Messages
161
Hello

2 questions

- What could be the best process to monitor if a txt file as been modified.

- How can i monitor the escape key press from the keyboard

Martin
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
mtheriault,

What could be the best process to monitor if a txt file as been modified.


One way, before the macro:

Excel Workbook
AB
1FileLast Date Modified
2Test.txt
Sheet1




After the macro:

Excel Workbook
AB
1FileLast Date Modified
2Test.txt2/24/2009 8:46 AM
Sheet1




Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Press and hold down the 'ALT' key, and press the 'F11' key.

On the 'Insert' menu, click 'Module'.

Copy the below code, and paste it into the Module (on the right pane).


Code:
Option Explicit
Sub GetDate()
    Dim fso, f
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    '**************************************************
    'Change the path and file name, from this:
    'Set f = fso.GetFile("C:\TestData\Test.txt")
    'to??????
    'Set f = fso.GetFile("C:\Test.txt")
    '**************************************************
    
    Set f = fso.GetFile("C:\TestData\Test.txt")

    '**************************************************
    'Change the range to where you want the date and time to go
    '**************************************************
    
    Range("B2").Formula = f.DateLastModified
    Range("B2").Select
End Sub


Then run the "GetDate" macro.


Have a great day,
Stan
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top