LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to lmport a text file and save it as an excel file using vb s.

I am trying to import a text file and save it as a normal excel file in VB
Script. I first recorded a macro that has steps to open the text file parse
it into columns and save it into a excel 2003 file. However when I copy and
past the macro with changes necessary for the VB script , vb script either
fails in the save-as step or brings up an interactive diaglog box for saving.
What is the way todo with out bringing up the diaglog box. Below is my simple
code..

Dim oXcel
Set oxcel = CreateObject("excel.Application")
oxcel.workbooks.add
oxcel.workbooks.OpenText "MyFile.txt"
oxcel.Rows("1:1").Select
oxcel.Selection.Font.Bold = True
oxcel.Columns("A:J").Select
oxcel.Range("J1").Activate
oxcel.Selection.Columns.AutoFit

ON Error Resume Next
oxcel.workbooks.SaveAs "MyFile.xls",4
if err.number < 0 then
wscript.echo "SaveAs error:",err.description
end if

On Error goto 0
oxcel.quit
Set oxcel = Nothing

=====
thanks
Newbie Scriptor
 
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 do I save an excel file as a file with undelimited text Lori Excel Discussion (Misc queries) 3 October 16th 07 11:04 PM
How do you save an excel file to be read as IBM-type text file ? Dee Franklin Excel Worksheet Functions 2 October 10th 06 02:46 AM
How can I save a file as a comma-delimited text file in Excel? LAM Excel Discussion (Misc queries) 1 May 3rd 05 10:24 PM
Excel VBA - open text file, replace text, save file? Cybert Excel Programming 2 October 2nd 04 01:05 AM
Excel VBA to save .xls file as UTF-8 text file match5man Excel Programming 0 June 3rd 04 11:41 AM


All times are GMT +1. The time now is 04:26 PM.

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"