Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!pacbell!rtech!dosbears!drp From: drp@dosbears.UUCP (David R. Preston) Newsgroups: comp.windows.ms Subject: Re: Need autosave macro for Winword Message-ID: <376@dosbears> Date: 3 Jun 91 04:32:48 GMT References: <1991Jun1.082921.13846@cunixf.cc.columbia.edu> Reply-To: drp%dosbears.uucp@ingres.com (David R. Preston) Organization: DosBears Lines: 125 In article <1991Jun1.082921.13846@cunixf.cc.columbia.edu> gg2@cunixf.cc.columbia.edu (Guy Gallo) writes: > >Did you ever fiddle with creating a macro to turn AutoSave on and off? Yes, here it is. The thing that bugs me is that there is no temporary variable space, so I have to use a "glossary"; if the glossary doesn't end up the same as when WinWord is started, you get the "save glossary?" prompt when you exit. I haven't made this macro "user friendly", so if you do something like hit the cancel button, you get an error. Also, if you close all documents before exiting Word, you might get an error. These errors should be ignored. There are two macros in this post: saveinit and savenow. Follow the instructions in Guy's previous post to get started. If you're using a defined key or menu to start savenow, it should be changed to start saveinit instead. Savenow should only be run by saveinit. Saveinit should be run when you want to start savenow and when you want to stop it (using the abort option). -----MACRO: saveinit-------------------- Sub MAIN Begin Dialog UserDialog 300, 100 OKButton 220, 6, 64, 18 CancelButton 220, 32, 64, 18 Text 65, 5, 96, 12, "current only" Text 65, 25, 96, 12, "with backup" Text 65, 45, 96, 12, "w/out fastsave" Text 65, 65, 96, 12, "save all" Text 65, 85, 96, 12, "abort" OptionGroup .mode OptionButton 50, 5, 24, 12, "&1" OptionButton 50, 25, 24, 12, "&2" OptionButton 50, 45, 24, 12, "&4" OptionButton 50, 65, 24, 12, "&8" OptionButton 50, 85, 24, 12, "&8" End Dialog Dim dlg As Dialog UserDialog Dialog dlg Select Case dlg.mode Case 0 SetGlossary "save", "1" Case 1 SetGlossary "save", "2" Case 2 SetGlossary "save", "3" Case 3 SetGlossary "save", "4" Case 4 SetGlossary "save", "0" End Select If dlg.mode < 4 Then MacroRun "savenow" Else EditGlossary "save", .Delete End If End Sub ------MACRO: savenow------------------------- Sub MAIN mode$ = GetGlossary$("save") name$ = FileName$(0) If mode$ <> "" And name$ <> "" Then If IsDirty() Then Select Case Val(mode$) Case 1 FileSave Case 2 FileSaveAs name$, 0, 0, 1, 0 Case 3 FileSaveAs name$, 0, 0, 0, 0 Case 4 FileSaveAll End Select End If nextime$ = getime$(1) OnTime nextime$, "savenow" Else Print "save aborted" End If End Sub Function getime$(n) now$ = Time$() ap$ = Right$(now$, 2) hour = Val(Left$(now$, 2)) min = Val(Mid$(now$, 4, 2)) min = min + n If min > 59 Then min = min - 60 hour = hour + 1 End If If ap$ = "PM" And hour <> 12 Then hour = hour + 12 End If If hour = 24 Then hour = 0 End If If min = 0 Then min$ = "00" ElseIf min < 10 Then min$ = "0" + Right$(Str$(min), 1) Else min$ = Right$(Str$(min), 2) End If If hour = 0 Then hour$ = "00" ElseIf hour < 12 Then hour$ = "0" + Right$(Str$(hour), 1) Else hour$ = Right$(Str$(hour), 2) End If getime$ = hour$ + ":" + min$ End Function ------------------------------------------------ -- David R. Preston drp%dosbears.uucp@ingres.com The world hadn't ever had so many moving parts or so few labels. D. R. Preston 584 Castro St. #614 SF CA 94114 USA