Log file modification

aliaslamy2k

Active Member
Joined
Sep 15, 2009
Messages
396
Office Version
  1. 2010
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
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
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
 

aliaslamy2k

Active Member
Joined
Sep 15, 2009
Messages
396
Office Version
  1. 2010
Platform
  1. Windows
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
 

ravishankar

Well-known Member
Joined
Feb 23, 2006
Messages
3,566
HI
try
Code:
Print #1,"Record updated  at " & Now & " by " & Application.UserName
ravi
 

aliaslamy2k

Active Member
Joined
Sep 15, 2009
Messages
396
Office Version
  1. 2010
Platform
  1. Windows
Dear experts,

Please give me a macro which automatically updates the logfile simultaniously once user save the database :confused:.
 

crimson_b1ade

Well-known Member
Joined
Sep 27, 2008
Messages
1,557
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,477
Messages
5,601,893
Members
414,479
Latest member
Beau the dog

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
Top