Log file modification

aliaslamy2k

Active Member
Joined
Sep 15, 2009
Messages
416
Office Version
  1. 2019
Platform
  1. Windows
Dear Colleagues,

I need a code which created a log file when any record is updated in excel, I found one similar code, but i dont know how to modify.

Private Sub EnterButton_Click()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
Dim PWord As String<o:p></o:p>
PWord = "Password"<o:p></o:p>
<o:p></o:p>
Open "C:\Password Log.txt" For Append Access Write As #1<o:p></o:p>
Print #1, Now & "- Password Attempt"<o:p></o:p>
Print #1, Application.UserName<o:p></o:p>



The log file looks this

11/21/2009 4:14:12 AM- Password attempt
02963
11/21/2009 4:17:21 AM- Password attempt
02963

But I need to change it as record updated.


Rgds,
AB
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi
try
Code:
Private Sub EnterButton_Click()
Open "C:\Password Log.txt" For Append Access Write As #1
Print #1, "Record updated " at " & Now & " by " & Application.UserName
end sub
Ravi
 
Upvote 0
Dear Ravi,

Thanks a million to reply, but I am not getting time stamp. Below is the response of log file.

Record updated & Now & & Application.UserName

and secondly I have to close and re-open the workbook to get log
file updated other wise its not updating.

I need the log file to get updated once the user save the data.

Thanks,
AB
 
Upvote 0
Dear experts,

Please give me a macro which automatically updates the logfile simultaniously once user save the database :confused:.
 
Upvote 0
maybe this...paste the below code to the 'ThisWorkbook' module.

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
 
Open "C:\Password Log.txt" For Append Access Write As #1
Print #1, "Record updated  at " & Now & " by " & Application.UserName

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

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