Auto save as text and close in code?

  • Thread starter Thread starter GD
  • Start date Start date
G

GD

Upon opening C:\Download\PBDB\CMDM.xls, I need to automatically save it as a
..txt file in the same folder, and then close it. Can someone help me with
the code I'd need for that?

Thanks!!
 
Assuming workbook is a single worksheet (you can't save multiple sheets in a
text file)

Open the VBA editor, go to the ThisWorkbook module, and paste this in. Do
note that this arrangement could be very annoying to anyone trying to open
the workbook for editing.

Private Sub Workbook_Open()
ThisWorkbook.SaveAs Filename:= _
"C:\Download\PBDB\CMDM.txt", FileFormat:= _
xlUnicodeText, CreateBackup:=False
Application.DisplayAlerts = False
ThisWorkbook.Close
End Sub
 
Back
Top