Counter macro

H

Herpenc

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

Helmut Weber

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/
 

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