RE: Log File



Hello Anand

Thanks for your response. I have attempted to copy it into a module but the
code complains of a compile error when the "write line" statement is
inserted, that a # sign is missing. I wrapped # signs around the statement as
follows:

Write #filenu#, .Path & "\" & .Name

but when the code is compiled it complains that:

Type declaration character does not match declared data type

Any suggestions.

Regards
--
JoeBo


"Anand.V.V.N" wrote:

> 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: 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: Is it possible for me to have an alert pop-up when I open a do
    ... Dim WeekOfPos As Long ... After I enabled macros and changed the security level, as per Dave Peterson, ... I got almost what I wanted, except that the pop-up box contains the font ... header of the activesheet when the workbook opens. ...
    (microsoft.public.excel.misc)
  • Re: Is it possible for me to have an alert pop-up when I open a do
    ... When you open the workbook you will be asked if you want to enable macros. ... Gord Dibben MS Excel MVP ... author using a certificate issued by a Certificate Autority." ... header of the activesheet when the workbook opens. ...
    (microsoft.public.excel.misc)
  • Re: File has Macros?
    ... good idea to open it first with macros disabled, ... & Add-ins to see what template the doc is based on. ... Then open the RTF, Save As Word Doc & you should be good to go. ... If I open the rtf and it opens in Word and save as Word doc, ...
    (microsoft.public.mac.office.word)
  • Re: Open User Form from Template and populate message
    ... I do not care that my security settings ask me to enable macros. ... The intention is to make a self contained macro in the template that only ... Having macros that activate when Outlook ... opens is not an option due to it compromising system security. ...
    (microsoft.public.outlook.program_vba)