Visual Basic (VB6 and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

Visual Basic Library

This page was last updated on Saturday, November 24, 2001

Public Sub AutoClose() ' This set of macros will execute automatically whenever you Open, Close or Save a document. ' AutoClose, as an example, checks to see if the document is "dirty", that is, if it has changed since it was opened. ' If the document has changed, AutoClose puts a bookmark defined by the public constant strcBookMark, ' wherever the text cursor happens to be. ' Please inspect AutoOpen. If that macro finds a bookmark strcBookMark, it will jump there. ' In short, next time you open a document, you will be taken to where you left off editing. ' To test these macros manually, run AutoClose, place the text cursor elsewhere, then run AutoOpen; ' Your text cursor should jump back to the original position. ' The code here could well be placed in the Document object of a template such as Normal.dot ' You could replace my use of strcBookMark with strcApplication q.v. ' Procedure : AutoClose ' Description: If the document is "dirty", set a bookmark at the text cursor location. ' Copyright: Chris Greaves Inc. ' Inputs: None. ' Returns: None. ' Assumes: Nothing ' Side Effects: None. ' Tested: By the calls shown below. If ActiveDocument.Saved Then Else Call AutoSave ' to set the bookmark to strcBookMark End If 'Sub TESTAutoClose() ' Call AutoClose ' Select a chunk of text before calling this module ' Selection.HomeKey (wdStory) ' Call AutoOpen 'End Sub End Sub

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Monday, November 19, 2001

 

 

Hosted by www.Geocities.ws

1