There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot computer connection crash css dell display driver drivers email error ethernet excel explorer firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking nvidia outlook outlook 2003 outlook express partition printer problem router slow software sound startup trojan usb virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
VBS Script Help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Rollin_Again's Avatar
Distinguished Member with 2,872 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
07-Mar-2007, 07:56 PM #1
VBS Script Help
Does anyone know how to save an Excel file as text using VBS?

Regards,
Rollin
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
07-Mar-2007, 08:31 PM #2
text as in CSV?
Rollin_Again's Avatar
Distinguished Member with 2,872 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
07-Mar-2007, 09:32 PM #3
Not a CSV file but a tab delimited text file that will be opened with Notepad. If I was using VBA within Excel I could issue a command like
Code:
ActiveWorkbook.SaveAs Filename:= "C:\Test.txt" , FileFormat:=xlText
In my VBS script I have replaced "ActiveWorkbook" with "objExcel" which is the name of my workbook object but the code throws an error.

Code:
objExcel.SaveAs Filename:= "C:\Test.txt" , FileFormat:=xlText
The code will work when I change to what is listed below but unfortunately since I am not specifying the file format the text is garbled and out of place.

Code:
objExcel.SaveAs Filename("C:\Test.txt")
Regards,
Rollin
__________________
Protect your computer and keep it free of pests and other spyware. Download AdAware, Spybot, ZoneAlarm and lots of other great utilities at PC World / SnapFiles / Major Geeks, Tech Guy Stuff

Help Keep this site free by making a small donation

http://www.techguy.org/donate.html

tsghelp / support
Jimmy the Hand's Avatar
Senior Member with 794 posts.
 
Join Date: Jul 2006
Location: Hungary
Experience: With Excel, fairly good.
08-Mar-2007, 11:38 AM #4
I don't know about VBS, but xlText is surely an Excel constant, which might not be understood by VBS compiler. Try using an integer constant, instead.

I run this macro in Excel to obtain integer values
Code:
Sub test()
    MsgBox xlText
    MsgBox xlTextWindows
    MsgBox xlUnicodeText
End Sub
Results:
xlText = -4158
xlTextWindows = 20
xlUnicodeText = 42

-4158 is a bit suspicious, I must admit... but maybe 20 or 42 will work.

Jimmy
__________________
'
It is advised to provide a clear, detailed description of the task, so that others can understand it, and offer the best possible help. Otherwise, you risk experts ignoring your request.
Rollin_Again's Avatar
Distinguished Member with 2,872 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
08-Mar-2007, 09:44 PM #5
Instead of my original plan to save the Excel file as text format, I've modified my VBS Script to create a new text file and to write the string values to it line by line. It works fine and my problem is solved for now but I will still give your recommendation a shot because I really want to know if there is another way to do this.

Regards,
Rollin
__________________
Protect your computer and keep it free of pests and other spyware. Download AdAware, Spybot, ZoneAlarm and lots of other great utilities at PC World / SnapFiles / Major Geeks, Tech Guy Stuff

Help Keep this site free by making a small donation

http://www.techguy.org/donate.html

tsghelp / support
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:03 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.