Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    PA
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AutoClose side effects (Word97/VBA)

    I have a simple fax cover template that makes use of tables for formatting. It is easier to read and complete on screen if gridlines are turned off. I have a set of simple macros that accomplish this. The AutoOpen and AutoNew macros include a routine that determines the current gridline view state and stores it to a variable. Then it turns the gridlines off. The AutoClose macro restores the preexisting gridline view state. The AutoNew macro does some other things, but the foregoing is basically all that the AutoOpen and AutoClose macros do.

    I have noticed that, when closing a document based on this template, the status bar always indicates that the template is being saved. This occurs even though there are no intentional or discernable changes made to the template in the editing of the document. Also, options are set to prompt to save normal.dot changes. There is never a prompt whether to save the template. (Don't mean to confuse here. This document template is not Normal.dot, but I mention this only in the event that the "prompt to save Normal.dot" setting has an effect on the saving of document templates.)

    I have concluded that this behavior results from the existence of the AutoClose macro. In the past, I have seen AutoClose macros bypass the prompt to save changes to the document, thereby discarding the changes. While I have never seen this saving phenomenon, I am guessing that the blame falls on AutoClose. Here is the macro:
    <pre>Public Sub AutoClose()

    ActiveWindow.View.TableGridlines = TGl
    ActiveWindow.View.Type = VT

    End Sub
    </pre>


    For context, here is AutoOpen:

    <pre>Public Sub AutoOpen()
    TGl = ActiveWindow.View.TableGridlines
    VT = ActiveWindow.View.Type
    ActiveWindow.View.TableGridlines = False
    ViewRight.ViewRight
    End Sub
    </pre>


    The vairables are declared in the Decalarations portion of the module:
    <pre>Option Explicit
    Dim TGl As Boolean
    Dim VT As Long
    </pre>


    Is it the AutoClose that is causing the involuntary save of the template? Any suggestions as to how to prevent it?

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: AutoClose side effects (Word97/VBA)

    Art,

    Without having had a chance to test this, I'm just wondering if these view state settings are things that Word wants to save in the document template rather than the document - not sure but that also might explain the behavior.

    What if you put the following as the last line in the AutoClose:

    ActiveDocument.AttachedTemplate.Saved = True

    Gary

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    PA
    Posts
    246
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AutoClose side effects (Word97/VBA)

    Gary, your suggestion makes a lot of sense. I'll try it when I get into the office and report back. Thanks.

Posting Permissions

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