Solved export from excel to text file by batch

September 15, 2014 at 08:39:10
Specs: Windows XP
I notice that nbrane used to output to a text file

>> exl.vbs echo ac.SaveAs "%outp%",-4158

I tried looking up to see what the meaning of -4158 but did not have much success

I would like to output to Fixed Width *.prn from excel to a text file

I tried to find a number like -4158 to allow me to do this.

Can anyone help me?? is there a list of output values like -4158

BIG Thanks for you help...

See More: export from excel to text file by batch

Report •

September 15, 2014 at 09:35:30
✔ Best Answer
Dumped from Office 2010. The actual meaning can be found here:
Name                          Value
----                          -----
xlSYLK                            2
xlWKS                             4
xlWK1                             5
xlCSV                             6
xlDBF2                            7
xlDBF3                            8
xlDIF                             9
xlDBF4                           11
xlWJ2WD1                         14
xlWK3                            15
xlExcel2                         16
xlTemplate                       17
xlTemplate8                      17
xlAddIn                          18
xlAddIn8                         18
xlTextMac                        19
xlTextWindows                    20
xlTextMSDOS                      21
xlCSVMac                         22
xlCSVWindows                     23
xlCSVMSDOS                       24
xlIntlMacro                      25
xlIntlAddIn                      26
xlExcel2FarEast                  27
xlWorks2FarEast                  28
xlExcel3                         29
xlWK1FMT                         30
xlWK1ALL                         31
xlWK3FM3                         32
xlExcel4                         33
xlWQ1                            34
xlExcel4Workbook                 35
xlTextPrinter                    36
xlWK4                            38
xlExcel7                         39
xlExcel5                         39
xlWJ3                            40
xlWJ3FJ3                         41
xlUnicodeText                    42
xlExcel9795                      43
xlHtml                           44
xlWebArchive                     45
xlXMLSpreadsheet                 46
xlExcel12                        50
xlOpenXMLWorkbook                51
xlWorkbookDefault                51
xlOpenXMLWorkbookMacroEnabled    52
xlOpenXMLTemplateMacroEnabled    53
xlOpenXMLTemplate                54
xlOpenXMLAddIn                   55
xlExcel8                         56
xlOpenDocumentSpreadsheet        60
xlCurrentPlatformText         -4158
xlWorkbookNormal              -4143

How To Ask Questions The Smart Way

Report •

September 16, 2014 at 05:56:36

It worked great usning code 36 to produce .prn

I'm having a Problem on trying to resize the column to autofit:

>> exl.vbs echo set"%xls%").Worksheets("Sheet1").Columns("A:H").AutoFit

It does autofit but blowup:
Error: Object Required: "'
Code 800A1A8

Can any one help me with this?

I'm an rpg programmer having to fix a vb pgm.


@echo off

set xls=c:\Trustmark\TRUSTLOADOSCEOLA.xls

set outp=c:\Trustmark\trust

>> exl.vbs echo Dim xl

>> exl.vbs echo Set xl = WScript.CreateObject("Excel.Application")

>> exl.vbs echo xl.application.Visible = TRUE

>> exl.vbs echo xl.application.displayalerts=false

>> exl.vbs echo set"%xls%").Worksheets("Sheet1").Columns("A:H").AutoFit

>> exl.vbs echo ac.SaveAs "%outp%",36

>> exl.vbs echo xl.application.quit

wscript exl.vbs


Report •

September 16, 2014 at 08:41:58
It looks like AutoFit returns a boolean, so the line fails when it tries to save the boolean as an object. Not sure why you're saving the result, but I don't know why you're writing a batch file to write a VBScript either.

>>exl.vbs echo"%xls%").Worksheets("Sheet1").Columns("A:H").AutoFit

How To Ask Questions The Smart Way

Report •

Related Solutions

September 17, 2014 at 17:03:52
Thanks Razor2.3!

The reason I'm writing a batch file is because my company has not update the software in years. I think the batch file which is now huge and process about 50 files, was started back in 1998. Every time I touch on the topic of upgrading they let me know that it has been working for years. We don't have the programming man power and I don't have time to deal with rewriting all the process. I'm better at DOS batch programming than VB.
For the first time, we received an excel file to process and I have to make it fit into what they do. I had no idea how I was going to process the excel file in batch without a human being to open and do a save as to a .prn file. I found the answer here in this forum and thanks to you and others I have been able to integrate the excel file into the process. We are all approaching retirement in our shop and once we leave maybe younger people will take on the upgrade cause.
Again, thanks for taking the time to read and evaluate the script and helping me get through this.

Report •

Ask Question