Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Saving as Sheet as a Tab Delimited Text file

am trying to write a Macro where I save the Sheet name Template as a Text
file in the current directory with a name format of TemplateMonthYear.txt.

Then I want to save the entire workbook with the name format of
TemplateMonthYear.xls.

I keep getting error messages when it tries to execute the statement

Sheets("Template").SaveAs Filename:= _
"Template" & AcctMth & AcctYear & ".txt", _
FileFormat:=xlText, CreateBackup:=False

Am I using the right statement to save a Sheet in a woorkbook as a tab
delimited text file?

Sub SaveTextFile()
'
' SaveTextFile Macro
'
Dim AcctYear, AcctMth
ActiveWorkbook.Save
Sheets("Template").Select
Range("AcctgPeriod").Select
AcctMth = Str(Month(Range("AcctgPeriod").Value))
AcctYear = Str(Year(Range("AcctgPeriod").Value))
Sheets("Template").Select
Sheets("Template").SaveAs Filename:= _
"Template" & AcctMth & AcctYear & ".txt", _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.SaveAs Filename:= _
"JIBUpload" & AcctMth & AcctYear & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200610/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Saving as Sheet as a Tab Delimited Text file

Try changing the term 'xlText' to 'xlTextWindows'. Even though the macro
recorder produces xlText as the FileFormat, xlText is not listed as a valid
filetype...

--
Jay


"Fredriksson via OfficeKB.com" wrote:

am trying to write a Macro where I save the Sheet name Template as a Text
file in the current directory with a name format of TemplateMonthYear.txt.

Then I want to save the entire workbook with the name format of
TemplateMonthYear.xls.

I keep getting error messages when it tries to execute the statement

Sheets("Template").SaveAs Filename:= _
"Template" & AcctMth & AcctYear & ".txt", _
FileFormat:=xlText, CreateBackup:=False

Am I using the right statement to save a Sheet in a woorkbook as a tab
delimited text file?

Sub SaveTextFile()
'
' SaveTextFile Macro
'
Dim AcctYear, AcctMth
ActiveWorkbook.Save
Sheets("Template").Select
Range("AcctgPeriod").Select
AcctMth = Str(Month(Range("AcctgPeriod").Value))
AcctYear = Str(Year(Range("AcctgPeriod").Value))
Sheets("Template").Select
Sheets("Template").SaveAs Filename:= _
"Template" & AcctMth & AcctYear & ".txt", _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.SaveAs Filename:= _
"JIBUpload" & AcctMth & AcctYear & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200610/1


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Saving as Sheet as a Tab Delimited Text file

If you check the Object Browser, you will see that "xlText" is a memebr of
the "XlPivotFieldDataType" enum, with a value of
Const xlText = -4158 (&HFFFFEFC2).

What you actually need is a member of the "XlFileFormat" enum. I would
assume one of these :
Const xlTextWindows = 20 (&H14)
Const xlUnicodeText = 42 (&H2A)

NickHK

"Fredriksson via OfficeKB.com" <u27002@uwe wrote in message
news:688e4e119901b@uwe...
am trying to write a Macro where I save the Sheet name Template as a Text
file in the current directory with a name format of TemplateMonthYear.txt.

Then I want to save the entire workbook with the name format of
TemplateMonthYear.xls.

I keep getting error messages when it tries to execute the statement

Sheets("Template").SaveAs Filename:= _
"Template" & AcctMth & AcctYear & ".txt", _
FileFormat:=xlText, CreateBackup:=False

Am I using the right statement to save a Sheet in a woorkbook as a tab
delimited text file?

Sub SaveTextFile()
'
' SaveTextFile Macro
'
Dim AcctYear, AcctMth
ActiveWorkbook.Save
Sheets("Template").Select
Range("AcctgPeriod").Select
AcctMth = Str(Month(Range("AcctgPeriod").Value))
AcctYear = Str(Year(Range("AcctgPeriod").Value))
Sheets("Template").Select
Sheets("Template").SaveAs Filename:= _
"Template" & AcctMth & AcctYear & ".txt", _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.SaveAs Filename:= _
"JIBUpload" & AcctMth & AcctYear & ".xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200610/1



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
Saving as text(tab delimited) file Pam New Users to Excel 1 November 4th 09 01:30 AM
Saving Excel sheet as a semicolon delimited file (.csv) e_dog95 Excel Discussion (Misc queries) 1 February 18th 06 11:02 PM
Saving multi-tab excel file created from comma delimited text file Marcus Aurelius Excel Programming 2 December 19th 05 05:16 PM
saving file as text(tab delimited)... Sevgi Excel Discussion (Misc queries) 1 April 6th 05 07:04 PM
saving excel file as tab delimited text programmatically Philip[_4_] Excel Programming 0 October 23rd 03 10:12 AM


All times are GMT +1. The time now is 03:25 AM.

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

About Us

"It's about Microsoft Excel"