Microsoft KB Archive/155991

From BetaArchive Wiki
Knowledge Base


WD97: Title Bar File Name Is Not Updated When You Use ActiveWindow.Caption

Article ID: 155991

Article Last Modified on 1/19/2007



APPLIES TO

  • Microsoft Word 97 Standard Edition



This article was previously published under Q155991


SYMPTOMS

When you use the ActiveDocument.ActiveWindow.Caption statement in a Microsoft Visual Basic for Applications macro (for example, a FileSaveAs or FileOpen macro), Word fails to update the title bar when you save the document with a new file name.

NOTE: Word saves the document but does not update the title bar in the open document. When you close and reopen the document, the title bar displays the correct file name.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.  This problem was corrected in Microsoft Word 2000.


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:


For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

173707 OFF97: How to Run Sample Code from Knowledge Base Articles


This problem can best be demonstrated by using the following steps:

  1. Start Word.
  2. On the Tools menu, point to Macro and then click Macros.
  3. In the Macros dialog box, change the Macros in box to Word Commands.
  4. In the Macro names list, click to select FileOpen.
  5. Change the Macros in box to the template that you want the macro saved to (for example, Normal.dot (global template)), and then click Create.
  6. Change the FileOpen macro to the following:

    Sub FileOpen()
    
       Dialogs(wdDialogFileOpen).Show
       ActiveDocument.ActiveWindow.Caption = _
          ActiveDocument.ActiveWindow.Caption + " - My Caption"
    
    End Sub
                        
  7. On the File menu, click Close and Return to Microsoft Word.
  8. On the Tools menu, point to Macro and then click Macros.
  9. In the Macros dialog box, change the Macros in box to Word Commands.
  10. In the Macro names list, click to select FileSaveAs.
  11. Change the Macros in box to the template that you want the macro saved to (for example, Normal.dot (global template)), and then click Create.
  12. Change the FileSaveAs macro to the following:

    Sub FileSaveAs()
    
       Dialogs(wdDialogFileSaveAs).Show
       ActiveDocument.ActiveWindow.Caption = _
          ActiveDocument.ActiveWindow.Caption + " - My Caption"
    
    End Sub
                        
  13. On the File menu, click Close and Return to Microsoft Word.
  14. On the Tools menu, click Open and open a Word document. The title bar for the document should now appear similar to the following:

    Microsoft Word - MyDocument.doc - My Caption

  15. On the File menu, click Save As, and save your Word document with a different file name.

Result: The Word document title bar is not updated with the saved file name.

REFERENCES

For additional information about getting help with Visual Basic for Applications, click the article number below to view the article in the Microsoft Knowledge Base:

163425 WD97: Macro Programming Resources


163435 VBA: Programming Resources for Visual Basic for Applications



Additional query words: wordcon vb vba vbe

Keywords: kbbug kbdtacode kbfix kbprogramming KB155991