PDA

View Full Version : Solved: Saving workbook as a textfile...



WebGuy
07-17-2006, 02:30 AM
Hi !
I am trying to save a copy of my workbook main page as a textfile, but i do not want the original workbook ("Main") to change its name to "hwspec.txt". I have checked for previous posts, but i cant seem to find an answer .
the code i am using to save is :


SaveTXT = MsgBox(Prompt:="Save hardware specs as a textfile ?", Buttons:=vbYesNo + vbQuestion)
If SaveTXT = vbYes Then
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\STLARSHE\Desktop\Excel\Logbok\HWSpecl.txt", _
FileFormat:=xlText, CreateBackup:=False
End If


Thank you !

ALe
07-17-2006, 02:35 AM
why don't you use savecopyas instead of saveas?

WebGuy
07-17-2006, 03:41 AM
I don't know how to format my file as a readable textfile when i use savecopyas.
When i try to open the textfile saved with savecopyas i just get a bunch of nonsens ..
I want to save the file as an xlText file.

ALe
07-17-2006, 05:22 AM
SaveTXT = MsgBox(Prompt:="Save hardware specs as a textfile ?", Buttons:=vbYesNo + vbQuestion)
If SaveTXT = vbYes Then
ActiveWorkbook.SaveCopyAs Filename:= _
"C:\Documents and Settings\STLARSHE\Desktop\Excel\Logbok\HWSpecl.xls"
Workbooks.Open "C:\Documents and Settings\STLARSHE\Desktop\Excel\Logbok\HWSpecl.xls"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\STLARSHE\Desktop\Excel\Logbok\HWSpecl.txt", _
FileFormat:=xlText, CreateBackup:=False

ActiveWorkbook.Close False
Kill "C:\Documents and Settings\STLARSHE\Desktop\Excel\Logbok\HWSpecl.xls"
End If

WebGuy
07-17-2006, 05:30 AM
Sweet !
Yep , that works nicely !
Thank you ALe!

ALe
07-17-2006, 05:42 AM
you welcome