Word "dirty bit" event macro?

J

Jorge Telman

I would like to change the titlebar of my word documents to reflect their
modification state. Either they are dirty or clean (changed, or unchanged
since last save).

Example titlebar:
c:\doc\filename (modified)
or
c:\doc\filename (unmodified)

This is how wordperfect looks, and it helps to know when a document needs
saving or not.

Is there an event I can tap into to do this?

I can set a timer to loop forever and check the saved property of the
document, but this doesn't seem like the right way to do it.

Any pointers would be appreciated.
Thanks.
 
J

Jezebel

No, there's no easy way to do this in Word. Why not turn on AutoSave and
make the question irrelevant?
 
M

Martin Seelhofer

Hey there

Well the timer-approach does not seem *that* bad to me
when using Application.OnTime:

' flag used to stop the macro from running
Dim isRunning As Boolean

' the pseudo-timer macro
Sub CaptionTimer()
Dim cap As String
Dim pos As Long
cap = Application.Caption

' check if mark already in title bar
pos = InStr(1, cap, "modified)")
If pos > 0 Then
' cut away mark
cap = RTrim(Left(cap, InStr(1, cap, "(") - 1))
End If

If ActiveDocument.Saved = False Then
cap = cap & " (modified)"
Else
cap = cap & " (unmodified)"
End If
Application.Caption = cap

' force macro to rerun in a second
If isRunning Then
Application.OnTime Now() + TimeValue("00:00:01"), "CaptionTimer"
End If
End Sub

Sub StartCaptionTimer()
isRunning = True
Call CaptionTimer
End Sub

Sub StopCaptionTimer()
isRunning = False
End Sub

If you call StartCaptionTimer() in an AutoExec-Macro of an AddIn
(global template in the startup folder), you pretty much have what you
wanted, don't you?

(Note that, since Word can have only one active OnTime-Timer,
this method might interfere with other AddIns relying on
Application.OnTime...)


Cheers,
Martin
 
W

Word Heretic

G'day "Martin Seelhofer" <[email protected]>,

the only problem with Timer events is any other tool using it as well
cancels yours as only 1 event is active at a time.

Steve Hudson
Word Heretic Sydney Australia
Tricky stuff with Word or words

Email: WordHeretic at tpg.com.au


Martin Seelhofer was spinning this yarn:
 
M

Martin Seelhofer

Hey there
the only problem with Timer events is any other tool using it as well
cancels yours as only 1 event is active at a time.

That's exactly what I wanted to point out with my note in brackets
on the bottom of my posting ;-)


Cheers,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top