vba using save as without opening the file

Viewed 10422

Is there any way to use ActiveWorkbook.SaveAs without opening the destination file?

My main Workbook called TEC ALOC EXT has a code to when it's saved it's generate another file without macros in a different path (using FileFormat:=51) called ALOCACAO TECNICOS. But this type of FileFormat also opens the destination file (ALOCACAO TECNICOS) at the end and closes the TEC ALOC EXT worksheet.

This it not good for me because I want to keep changing things on my TEC ALOC SHEET sheet.

Is there any way to just save the ALOCACAO TECNICOSwithout opening it?

Here is my code:

Sub CopiarNovaPlanilha()

Application.EnableEvents = False
Application.DisplayAlerts = False

ActiveWorkbook.SaveAs "I:\CGP\DEOPEX\01 - Supervisão\10 - Alocação das equipes\Consulta Alocados\ALOCACAO TECNICOS", FileFormat:=51

ActiveWorkbook.Sheets(1).Name = "FUNCIONARIOS"


Application.EnableEvents = True
Application.DisplayAlerts = True

End Sub

That is triggered by AfterSave event:

Private Sub Workbook_AfterSave(ByVal Success As Boolean)

If Success Then


Call CopiarNovaPlanilha


End If

End Sub
2 Answers
Related