Excel program

2007-07-09 9:22 pm
Is there any methods for producing a log file(recording all steps when someone have edited,printed or .....when opening a Excel file). Is it necessary to make a Marco to proceed it?

回答 (2)

2007-07-11 4:31 am
✔ 最佳答案




It is conceptually achievable by writing some event handlers on the Workbook object to log some common actions taken by the user.
You may write the VBA as an Excel template, and create new workbooks from this template. Then the new workbooks will have the logging function.



Screenshots



Open Excel, select File → New...:




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log01.gif




Select log.xlt, click Ok:




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log02.gif




Click the Log sheet tab to see the log:




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log03.gif




Edit and print Sheet1 and then save, close and re-open the workbook, etc...




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log04.gif




...will produce a log like this:




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log05.gif




Excel Template: log.xlt



The Excel template is named log.xlt. Besides event handlers, it contains a Module and a Class Module.




Event Handlers




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log06.gif




Module




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log07.gif




Class Module




圖片參考:http://i206.photobucket.com/albums/bb265/a048042l/log08.gif





Drawback



Since VBA is involved in updating the log sheet, the undo/repeat function is rendered unusable.
This can be solved by using an external text file for logging, rather than using a worksheet. However, it is still not a perfect solution.



Source Code



Click here to download log.xlt from Sendspace.com.
(The download link is near the bottom of the page, just beside the shaking red arrow)



Note



Put the template into the Office template directory for Excel to locate it:

C:\Documents and Settings\Your User Name\Application Data\Microsoft\Templates



參考: 原創
2007-07-11 2:35 am
1) create an WORKBOOK_OPEN() macro.
2) Use the RECORDMACRO method to record everything typed by user.
3) create a macro to close and save the excel file when exit excel.
DONE. You can then edit the macro recorded to see what had been typed by the user.


收錄日期: 2021-04-27 13:21:10
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070709000051KK01710

檢視 Wayback Machine 備份