The macro has to come in a .doc file and has to start another macro that is
placed in the MS Word startup directory. The macro have to start
automatically when the document is been opened for the first time. When the
document has been closed and startup again the macro may not start. There
have to come a counter on it.
The line below wil start the macro:
Sub auto_open()
Application.Run MacroName:="firstdoc_auto_open"
End Sub
But it does'nt start automatically and is has no counter on it. How can I do
this please help me. Thanks!!
Helmut Weber - 16 Mar 2005 19:18 GMT
Hi,
how about this one:
Sub autoopen()
On Error Resume Next
If ActiveDocument.Variables("OpenedBefore") = "" Then
ActiveDocument.Variables("OpenedBefore") = 1
MsgBox "first time"
ActiveDocument.Saved = False
ActiveDocument.Save
Exit Sub
Else
MsgBox "openend before" ' or run another macro
End If
End Sub
End Sub
Note: "autoopen", not "auto_open"
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/