![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Microsoft Office support MS Office support forum |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jul 2008
Posts: 4
OS: winxp
|
Excel worksheet converted to txt file
Hi,
I have large excel spreadsheet which i need to convert automaticaly to text file, and automaticaly name the file with specific name format (eg. date is part of the name -Nmmddyy1.txt. Is it possible.? I can do that by Save As, and choose txt document, but is there a way to do this with some command or macro? |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 94
OS: Windows XP SP3
|
Re: Excel worksheet converted to txt file
In that case, let's modify the macro a bit:
Code:
Sub mcrSave()
Dim fileSaveName As Variant
'Retrieve file name to use for Save
fileSaveName = Application.GetSaveAsFilename( _
fileFilter:="Text Files (*.txt), *.txt")
'If user specified file name, perform Save and display msgbox
If fileSaveName <> False Then
ActiveWorkbook.SaveAs Filename:=fileSaveName, FileFormat:=xlTextWindows
MsgBox "Save as " & fileSaveName
End If
End Sub
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Jul 2008
Posts: 4
OS: winxp
|
Re: Excel worksheet converted to txt file
thanks a lot mate, you are champ.
it works fine. can we put preset format as a file name, eg. instead of book1, i need for example Nddmmyy1.txt (N1107081.txt for today) Appreciate your help |
|
|
|
|
|
#6 (permalink) |
|
Registered User
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 94
OS: Windows XP SP3
|
Re: Excel worksheet converted to txt file
Okay, let's modify the line where we retrieve the file name to use for the save:
Code:
fileSaveName = Application.GetSaveAsFilename( _
InitialFilename:="N" & Format(Date, "ddmmyy") & "1.txt", _
fileFilter:="Text Files (*.txt), *.txt")
|
|
|
|
![]() |
| Thread Tools | |
|
|