RE: Log File



Hi,

Hope the sample code helps you.

Create a copy of the normal.dot nad then modify the normal.dot. You can
edit the macros, and modify the inbuilt macros for saving opening, and
closing file. I am not sure which are the macros.

Other way is to open the visual basic editor and in the open document, new
document, you can call a function called writelog, and write a function,
write the code there.

To get the path and name

ActiveDocument.Path gives you the document path
ActiveDocument.Name gives you the document name

open a text file in the path you want in append mode, and every time the
file is opened, closed or saved, you can call a function that opens the text
file in appened mode and usign this statement you can write the log.

in the function writelog use this code.

dim filnu
filenu=Freefile

open <path><filename> for append as filenu 'repalce the path and filename
with the opat and filename,

with activedocument
if len( activedocument.path) > 3 then
write filenu, .path &"\" & .name ' if it is not the root directory, eg
"c:\path1.
else
write filenu, .path & .name ' if it is the root directory, eg "c:"
endif

'Use format function to write the date and time
write filenu,format(now(),"dd,dddd,mmmm,yyyy") 'any other format also can be
used like "dd/mm/yy" or "d,dd,dddd,mmmm,yyyy", "mm-dd-yy" etc

write filenu,format(now(),"hh:ss:mm")

close filenu

Hope you found this helpful. Is this what you wanted?

Anand
--
"Who will guard the guards?"


"JoeBo" wrote:

> I need some code that will add the filename and path as well as the current
> date and time to a log file called word files.txt each time a word document
> is opened or saved. Anyone Help
>
> Regards
>
> JoeBo
.



Relevant Pages

  • Re: Protecting a word document
    ... You need to put the contents of the word document in a place ... that is only accessible to macros. ... This message is posted to a newsgroup. ... If a user opens this document and chooses ...
    (microsoft.public.word.vba.beginners)
  • Open document and ignoring macros
    ... I have VBA code that opens a word document using: ... how can I tell Word to open the document and ignoe or disable the auto macros? ...
    (microsoft.public.word.vba.general)
  • Re: Copying Macros
    ... > I have written several macros within a Word document. ... > is an autoopen macro that opens another document which ... > performs some automated editing. ...
    (microsoft.public.word.vba.general)
  • RE: New clue! Open/Close other workbooks with VBA;
    ... File 1 opens and closes as expected. ... the old workbook number 1 processed after that ... ... it went to open Gort (the original copy, still with macros) and it died as ... Dim secAutomation As MsoAutomationSecurity ...
    (microsoft.public.excel.programming)
  • Re: Modifying a record field value while not blocking it to others
    ... as it is effective only when you go out of the related field you just ... And of course again the record you are trying to modify has not to be 'open' ... someone opens that ID=12 record everything in it is locked. ... so the developer has to create their own work-around. ...
    (comp.databases.filemaker)

Loading