saves normal document

B

Bruno Coelho

hi, i have this simple code that saves to a normal document from a template.

Sub AutoClose()

Dim Savepath As String
Dim DocumentName As String
Dim box As String

Savepath = "G:\Administrativos\Credenciais de Deslocação\Dr. Carlos
Pinto\Credenciais Guardadas\"
box = InputBox("Qual o nome que deseja guardar", "Guardar")
DocumentName = box + Format(Now, "YYYY-MM-DD")

ActiveDocument.SaveAs FileName:=Savepath + DocumentName

End Sub

When i click on the close button it saves correctly and save it in normal
document, know, my question is when i open the normal document and close it
it appears again th InpuBox and saves again.
In the template, how can i do in VBA when save eliminate the code VBA of the
normal document.
Thanks
 
T

Tony Jollans

The AutoClose runs (from the template) every time you Close the document.

If you want to keep the same template attached to the document, perhaps the
easiest way is to check if the document has a path ..

Sub AutoClose()

Dim Savepath As String
Dim DocumentName As String
Dim box As String

If Activedocument.path <> "" then Exit sub

Savepath = "etc. etc.:
 

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