Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Auto save as text and close in code?
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!! -- GD |
#2
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Auto save as text and close in code?
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 -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "GD" wrote: 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!! -- GD |
#3
Posted to microsoft.public.excel.newusers
|
|||
|
|||
Auto save as text and close in code?
Awesome! Thanks, Luke!
P.S. I'm the only one who will need this file, so no worries. -- GD "Luke M" wrote: 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 -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "GD" wrote: 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!! -- GD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to code the Macro to save and close a file? | Excel Discussion (Misc queries) | |||
Auto run maco/change behavior of save/close | Excel Discussion (Misc queries) | |||
Auto Open, Refresh, Save, Close | Excel Discussion (Misc queries) | |||
Auto-save worksheet on close? | Excel Discussion (Misc queries) | |||
close form code | Excel Discussion (Misc queries) |