[comp.windows.ms] Need autosave macro for Winword

victor@ccwf.cc.utexas.edu (Victor Menayang) (05/29/91)

I need an autosave macro for Word for Windows.
(I don't like just being reminded :-)
Anybody has written such macro?
I would appreciate it if s/he could
send me a copy (or perhaps post here).



-- 
Victor Menayang         victor@ccwf.cc.utexas.edu (Internet) 
                                           vm@UTXVM (BITNET)
                     ...!cs.utexas.edu!ut-emx!rtf1000 (UUCP)
-------------------------------------------------------------

indra@ashirvad.amd.com (Indra Singhal) (05/30/91)

victor@ccwf.cc.utexas.edu (Victor Menayang) writes:


>I need an autosave macro for Word for Windows.
>(I don't like just being reminded :-)
>Anybody has written such macro?
>I would appreciate it if s/he could
>send me a copy (or perhaps post here).

The hDC First Apps contains a Micro App called AutoSave that will do the
autosave for all (or those you choose) applications in Windows based on
keystroke and/or elapsed time criteria!!

Check it out. The package is worth the price, in my "personal" opinion.

--
iNDRA | indra@amd.com or {ames apple uunet}!amd!indra
      | (Indra Singhal) (408) 749-5445; Advanced Micro Devices
      | MS 167; Box 3453; 901, Thompson Pl., Sunnyvale, CA 94088

gg2@cunixf.cc.columbia.edu (Guy Gallo) (05/30/91)

In article <1991May30.003620.23077@amd.com> indra@ashirvad.amd.com (Indra Singhal) writes:
>victor@ccwf.cc.utexas.edu (Victor Menayang) writes:
>
>
>>I need an autosave macro for Word for Windows.
>>(I don't like just being reminded :-)
>>Anybody has written such macro?
>>I would appreciate it if s/he could
>>send me a copy (or perhaps post here).

This was posted on the net some time back;  I assume the author would not
mind my reposting:


Are there any macros for Word for Windows publicly available?
I haven't seen any being posted, or on simtel.
The following is a very simple autosave macro to use instead of
the silly thing built into W4W that bugs you to save at random
intervals.  If you've never played with the macro feature:

        run W4W
        pull down the macro menu
        click on edit (in the macro menu)
        enter savenow for the macro name
        cut and paste the following macro into the macro editor
        save it and the global command changes

In order to use it, you'll either need to assign it to a menu,
assign it to a key, or have it run when you start W4W (more about
that after the macro).

................................cut here...................................

Sub MAIN
If IsDirty() Then
        FileSave
        End If
now$ = Time$()
ap$ = Right$(now$, 2)
hour =  Val(Left$(now$, 2))
min =  Val(Mid$(now$, 4, 2))
min = min + 4
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
        nextime$ = Right$(Str$(hour), 2) + ":00"
ElseIf min < 10 Then
        nextime$ = Right$(Str$(hour), 2) + ":0" + Right$(Str$(min), 1)
Else
        nextime$ = Right$(Str$(hour), 2) + ":" + Right$(Str$(min), 2)
        End If
OnTime nextime$, "savenow"
End Sub


.................................cut here..............................


If you'd like to have this run when you start W4W, create the macro
AutoExec and paste the following into it:

Sub MAIN
FileNew
If MsgBox("enable autosave?", 36) Then
        Print "autosave enabled"
        MacroRun "savenow"
        End If
End Sub

I expect to make this a little more sophisticated, and post a new version in
about a week, but I wanted to see if anyone else was writing macros.
-david

        preston@lll-crg.llnl.gov
        B4 f+ t- k+ s-/+ r P8/3 S6 b+/- g- l-/+ y- z/! n o+/++ x a+ u v-- j++
        D. R. Preston  584 Castro St. #614 SF CA 94114 USA

news@unixg.ubc.ca (Usenet News Maintenance) (05/30/91)

In article <1991May30.003620.23077@amd.com> indra@ashirvad.amd.com (Indra Singhal) writes:
>victor@ccwf.cc.utexas.edu (Victor Menayang) writes:
>
>
>>I need an autosave macro for Word for Windows.
>
>The hDC First Apps contains a Micro App called AutoSave that will do the
>autosave for all (or those you choose) applications in Windows based on
>keystroke and/or elapsed time criteria!!
>

There is also a shareware package on cica.cica.indiana.edu in the file
/pub/pc/win3/util/filesave.zip that will do the job.

Brian McCashin                            Internet: mccashin@unixg.ubc.ca
Senior Programmer/Analyst                 Bitnet: USERJAZZ@UBCMTSG
Centre For Health Services and Policy Research
University of British Columbia, Vancouver CANADA

victor@ccwf.cc.utexas.edu (Victor Menayang) (05/31/91)

In article <1991May30.063956.9027@cunixf.cc.columbia.edu> gg2@cunixf.cc.columbia.edu (Guy Gallo) writes:
>
>This was posted on the net some time back;  I assume the author would not
>mind my reposting:
>
>
Guy,
 Thank you for reposting the macro.
 Maybe you could put a copy of the mail at cica.


Thanks,

-- 
Victor Menayang         victor@ccwf.cc.utexas.edu (Internet) 
                                           vm@UTXVM (BITNET)
                     ...!cs.utexas.edu!ut-emx!rtf1000 (UUCP)
-------------------------------------------------------------

drp@dosbears.UUCP (David R. Preston) (05/31/91)

In article <1991May30.063956.9027@cunixf.cc.columbia.edu> gg2@cunixf.cc.columbia.edu (Guy Gallo) writes:
>>
>>>I need an autosave macro for Word for Windows.
>>>(I don't like just being reminded :-)
>>>Anybody has written such macro?
>>>I would appreciate it if s/he could
>>>send me a copy (or perhaps post here).
>
>This was posted on the net some time back;  I assume the author would not
>mind my reposting:

Not at all; saves me from trying to find my copy.  However, the
one I posted only worked certain hours of the day (probably the
same hours I work :-).  The following, I hope, accounts for all
of the problems of converting time formats.  I wrote a much more
elaborate version with a bunch of options, but it runs too slow
for something that is going to go off every n minutes, while
you're still trying to type.  Anyway, use the directions from
Guy's reposting of my first attempt, but substitute the following
for the macro:

__________________________________________________________________

Sub MAIN

If IsDirty() Then
	FileSave
End If
	nextime$ = getime$(4)
	OnTime nextime$, "savenow"
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

amf@ecs.soton.ac.uk (Andrew Fountain) (05/31/91)

In <1991May30.063956.9027@cunixf.cc.columbia.edu> gg2@cunixf.cc.columbia.edu (Guy Gallo) writes:

I think there is a bug here. If the time *was* between 11:56am and
11:59am, then after adding 4 mins the time will be between 12.00 and
12.03 but still be "am". It will have 12 added to it to make it 24.0x
I think the solution is to do the conversion from 12 to 24 hour clock
*before* adding in the 4 mins.

>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

-- 
amf@ecs.soton.ac.uk                  Dr. Andrew Fountain
Tel: +44 703 592831                  Dept of Electronics and Computer Science
Fax: +44 703 593045                  University of Southampton
Telex: 47661 SOTONU G                Southampton  SO9 5NH  England

cave@randvax.UUCP (Jonathan Cave) (05/31/91)

I don't seem to be able to get it to work.  When I create the macros,
everything seems OK.  When I run Trace to check it, I get Wordbasic
Error 118: Nested Sub or Function Defs.  Then the first column disappears.

When I enable it as an autosave macro, I get Wordbasic Error 100: syntax
error.  I haven't printed out TFM for WordBasic yet.  Am I doing something
obviously stupid?

I open the mail message, converting from text.
Then I select macro edit, with the name Savenow
I copy the macro text from the message and paste it into Savenow
I run trace and get error 118
I repaste it into Savenow to restore the first column
I macro edit autoexec, and paste in that part of the message
I save and exit
I start up WFW and get error 100

Any help greatly appreciated...

marshall@wind55.seri.gov (Marshall L. Buhl Jr.) (06/01/91)

victor@ccwf.cc.utexas.edu (Victor Menayang) writes:

>I need an autosave macro for Word for Windows.

I've seen the replies folks have made to this original posting.  They
don't solve the problem in a way I like.

I used to use Word for DOS 5 and it used a very different techinque.  It
did saves to a temporary scratch file every so many (specified) minutes.
When you quit your session, the file is removed.  If your system crashes
and you leave Word other than the standard way, the file still exists.
When you start Word up again, it asks if you want to recover the
autosave file.  This is similar to the way vi works in Unix.

The advantage over these other techniques is that your original file
only gets updates when you want it.  I often make major reformatting
changes and sometimes don't like the result.  I then restore my saved
file to throw the changes away.  With WfW's standard autosave, you can't
do this unless you ask to be prompted.  Being prompted is annoying.

What I want is Word 5's autosave feature for WfW.  I sent MS a letter
asking for it, but who knows if anything will be done.  There are still
many ways in which Word 5 is superior to WfW.  I hope the next version
of WfW will add most of these features.

Later,

Marshall
--
Marshall L. Buhl, Jr.             EMAIL: marshall@seri.gov
Senior Computer Engineer          VOICE: (303)231-1014
Wind Program                      1617 Cole Blvd., Golden, CO  80401-3393
Solar Energy Research Institute   Solar - safe energy for a healthy future

drp@dosbears.UUCP (David R. Preston) (06/01/91)

>In <1991May30.063956.9027@cunixf.cc.columbia.edu> gg2@cunixf.cc.columbia.edu (Guy Gallo) writes:
>
>I think there is a bug here. If the time *was* between 11:56am and
>11:59am, then after adding 4 mins the time will be between 12.00 and
>12.03 but still be "am". It will have 12 added to it to make it 24.0x

No, it won't.  Are you confusing noon and midnight?

>>If ap$ = "PM"  And hour <> 12 Then

ap$ not "PM", so don't add 12.

>I think the solution is to do the conversion from 12 to 24 hour clock
>*before* adding in the 4 mins.

I don't think that would help much, but I'll look at it.  By now
you've seen my posting of the one that actually works (the first
version didn't put in the non-significant zeroes).


--
          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

gg2@cunixf.cc.columbia.edu (Guy Gallo) (06/01/91)

Greetings, David.  

Did you ever fiddle with creating a macro to turn AutoSave on and off?  I might
add this (with your permission), although it might be that the next version
of WinWord will have a better AutoSave feature (we can hope).

BTW -- have you seen the macros on Cica?  I uploaded several of mine.  They 
all begin with "g"... Gtools gpsmrk gpsenv21 and the like...

drp@dosbears.UUCP (David R. Preston) (06/03/91)

In article <2965@randvax.UUCP> cave@randvax.UUCP (Jonathan Cave) writes:
>
>
>I don't seem to be able to get it to work.  When I create the macros,
>everything seems OK.  When I run Trace to check it, I get Wordbasic
>Error 118: Nested Sub or Function Defs.  Then the first column disappears.

When you create the macro, the editor starts you off with an empty

	Sub MAIN
	End Sub

If you paste a macro into this, you'll end up with:

	Sub MAIN
	Sub MAIN
	.
	.
	.
	End Sub
	End Sub

This is not good.  If you'll delete one of the pairs, it should
work a lot better.


--
          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

drp@dosbears.UUCP (David R. Preston) (06/03/91)

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

kpleas@milton.u.washington.edu (Keith Pleas) (06/07/91)

 (David R. Preston) writes:
>The thing that bugs me is that there is no temporary
>variable space, so I have to use a "glossary"

David:

Well, there are other options.
   1) Open a document with another template, and use THAT glossary.
   2) Use the temporary document opened in 1).
   3) Use the clipboard.  The clipboard can be used as a stack to put
      multiple pieces of info if they're separated by something (like
      a non-printing character).
   4) Use an .ini file.

drp@dosbears.UUCP (David R. Preston) (06/08/91)

In article <1991Jun7.021329.12392@milton.u.washington.edu> kpleas@milton.u.washington.edu (Keith Pleas) writes:
>
> (David R. Preston) writes:
>>The thing that bugs me is that there is no temporary
>>variable space, so I have to use a "glossary"
>
>David:
>
>Well, there are other options.
>   1) Open a document with another template, and use THAT glossary.
>   2) Use the temporary document opened in 1).
>   3) Use the clipboard.  The clipboard can be used as a stack to put
>      multiple pieces of info if they're separated by something (like
>      a non-printing character).
>   4) Use an .ini file.

I decided that using the glossary was more trouble that it's worth,
because I always get the "save glossary changes" dialog at the end
of a session.  I haven't tried using the clipboard (would that be
the same as using the "spike" glossary?  Maybe I should try the
spike), but I have been playing with using win.ini.  The SetProfileString
takes a fair amount of time, but the GetProfileString is faster.  I'll
be posting a simple version of autosave that can be turned off by use
of modifying the win.ini (i.e. save=on or save=off).  I'm also
working on autosave with a temp file like Marshall wanted.


--
          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