Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
GD GD is offline
external usenet poster
 
Posts: 83
Default 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   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,722
Default 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   Report Post  
Posted to microsoft.public.excel.newusers
GD GD is offline
external usenet poster
 
Posts: 83
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code the Macro to save and close a file? Eric Excel Discussion (Misc queries) 7 June 10th 07 03:28 PM
Auto run maco/change behavior of save/close m schmitz Excel Discussion (Misc queries) 0 February 10th 06 04:00 AM
Auto Open, Refresh, Save, Close Jimmycooker Excel Discussion (Misc queries) 0 February 6th 06 01:34 PM
Auto-save worksheet on close? [email protected] Excel Discussion (Misc queries) 1 January 2nd 06 02:12 PM
close form code tkaplan Excel Discussion (Misc queries) 1 June 3rd 05 10:49 PM


All times are GMT +1. The time now is 06:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"