Results 1 to 2 of 2
  1. #1
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Los Angeles, California, USA
    Thanked 2 Times in 2 Posts

    Removing personal info 'by default' (Word 2002 SP-2)

    I'd like to have "Remove personal information from this file on save" be True for all my files unless I reset it for a particular file (i.e., the opposite of Word's default).

    Per VB Help's instructions, I've created a WordEventsModule class module in my global macros template that consists entirely of the following lines:

    Public WithEvents App As Word.Application

    Private Sub App_NewDocument(ByVal Doc As Document)
    With ActiveDocument
    .RemovePersonalInformation = True
    End With
    End Sub

    And I've implemented the class module by declaring a public variable in the same global template (Public WordEvents As WordEventsModule) and running the following lines as part of the AutoExec macro:

    Set WordEvents = New WordEventsModule
    Set WordEvents.App = Word.Application

    This works, but (as usual) not quite perfectly. I have 2 questions:

    1. The glitch is that the App_NewDocument event isn't triggered for the initial blank document that Word creates by default when it starts. (The same non-result applies if you try to use the New event of the Document object.) I know there's a startup switch (/n) that causes Word to start without opening a blank document, but there are too many different ways Word can be started up for this to be a satisfactory solution. Another possible solution might be to let Word open the blank document and have the AutoExec macro close it, but that's a bit kludgey, and I assume I'd need to add code to make sure AutoExec didn't close a non-blank document that Word had been started to deal with. Anybody got the "best solution"?

    2. In choosing where to put the option-setting code, I chose App_NewDocument (in my global macros template) over Document_New (in the ThisDocument object in the Normal template) so I wouldn't have to worry about re-creating this event any time I wanted to rebuild my Normal template (because of corruption or whatever), and so I wouldn't have to duplicate it in every other template I use from time to time. But it occurs to me that I'll lose the App_NewDocument functionality during any Word session if anything happens that causes my project to Reset. Anyone have any advice on the "best way" to implement the option-setting code?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Removing personal info 'by default' (Word 2002 SP-2)

    How about hijacking FileSave?

    <pre><big>Sub FileSave()
    With ActiveDocument
    .RemovePersonalInformation = True
    If .Path = vbNullString Then
    End If
    End With
    End Sub</big></pre>

    I guess the problem is when there are several layers of FileSave, the global one might get preempted. I think there is an event you could hook into, but I forget its name. (Might be SomethingBeforeSave)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts