Page 1 of 1 1
Topic Options
#112002 - 2004-01-18 02:24 PM Creating .XLS from .CSV via EXCEL using COM
GMC Offline
Fresh Scripter

Registered: 2002-01-31
Posts: 17
Loc: Toronto,Canada
Hi Everybody

I just started using the COM feature to call EXCEL
Have had success by looking at other examples but cannot
finish what I need to do.
I can import a large .CSV files, make modifications via
COM but cannot seem to eliminate the prompts that appear
to ask me if I want to save the changes I made even though
I have defined the SaveAS file ad .XLS
I need the script to redefine the input from a CSV type
to a workbook type without prompts.
Also is there a way to list out all the properties
that can be called in EXCEL.
Even better would be some sort of beginner documentation
Thanks Gary



Top
#112003 - 2004-01-18 02:34 PM Re: Creating .XLS from .CSV via EXCEL using COM
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Might want to disable "DisplayAlerts" at the beginning or before you "Quit" ...

$oXL.DisplayAlerts = 0

-Shawn

Top
#112004 - 2004-01-18 04:06 PM Re: Creating .XLS from .CSV via EXCEL using COM
GMC Offline
Fresh Scripter

Registered: 2002-01-31
Posts: 17
Loc: Toronto,Canada
Thanks Shawn
That eliminates the prompt but did not convert the file to .XLS.
I beleive i need the right syntax to include FileFormat:=xlNormal ( from Macro record in EXCEL )

ex .ActiveWorkbook.Saveas ( FileName, FileFormat )

Or maybe some good examples

Thanks Gary

Top
#112005 - 2004-01-18 08:56 PM Re: Creating .XLS from .CSV via EXCEL using COM
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Here is an example line:

$oXL = $oXL.ActiveWorkbook.SaveAs("$SaveAs",-4143,"","",0,0,,,0)

from this thread:

Excel Importation Example

-Shawn

Top
#112006 - 2004-01-19 02:26 PM Re: Creating .XLS from .CSV via EXCEL using COM
GMC Offline
Fresh Scripter

Registered: 2002-01-31
Posts: 17
Loc: Toronto,Canada
Hi Shawn
Thanks very much that worked. Now I like to know how ?
All documention and examples seemed to be along the lines
of the following
.SaveAS Filename:=(FilePath), FileFormat:=xlNormal
How does -4143 equate to xlNormal
If you run the Macro recorder in Excel you will see.
Thank again Gary


Top
#112007 - 2004-01-19 02:54 PM Re: Creating .XLS from .CSV via EXCEL using COM
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
The value is a constant (aka enumeration), which is translated from the text value to an internal numeric value by the scripting or programming language.

KiXtart does not have access to these constants, so you have to do the translation manually.

Sometimes they are a bugger to find, and the only way to do it is to use an object viewer.

For reference, the xlFileFormat values for Excel 2002 are:
Quote:

typedef enum {
xlAddIn = 18,
xlCSV = 6,
xlCSVMac = 22,
xlCSVMSDOS = 24,
xlCSVWindows = 23,
xlDBF2 = 7,
xlDBF3 = 8,
xlDBF4 = 11,
xlDIF = 9,
xlExcel2 = 16,
xlExcel2FarEast = 27,
xlExcel3 = 29,
xlExcel4 = 33,
xlExcel5 = 39,
xlExcel7 = 39,
xlExcel9795 = 43,
xlExcel4Workbook = 35,
xlIntlAddIn = 26,
xlIntlMacro = 25,
xlWorkbookNormal = 0xffffefd1,
xlSYLK = 2,
xlTemplate = 17,
xlCurrentPlatformText = 0xffffefc2,
xlTextMac = 19,
xlTextMSDOS = 21,
xlTextPrinter = 36,
xlTextWindows = 20,
xlWJ2WD1 = 14,
xlWK1 = 5,
xlWK1ALL = 31,
xlWK1FMT = 30,
xlWK3 = 15,
xlWK4 = 38,
xlWK3FM3 = 32,
xlWKS = 4,
xlWorks2FarEast = 28,
xlWQ1 = 34,
xlWJ3 = 40,
xlWJ3FJ3 = 41,
xlUnicodeText = 42,
xlHtml = 44,
xlWebArchive = 45,
xlXMLSpreadsheet = 46
} XlFileFormat;

xlWorkbookNormal is a very large unsigned number, which appears to be a negative value when used in a signed data type.
Top
#112008 - 2004-01-20 02:49 PM Re: Creating .XLS from .CSV via EXCEL using COM
GMC Offline
Fresh Scripter

Registered: 2002-01-31
Posts: 17
Loc: Toronto,Canada
Thanks Richard
I am new at COM but was able to accomplish everthing I needed to do.
Is their a way to list all the properties of an object
from KIX. I was trying to get them using the EXCEL macro
recorder but was hung up translating the syntax to KIX
Thanks Gary


Top
#112009 - 2004-01-20 03:07 PM Re: Creating .XLS from .CSV via EXCEL using COM
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I think Richard answered that with:
Quote:

...the only way to do it is to use an object viewer


_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#112010 - 2004-01-20 03:10 PM Re: Creating .XLS from .CSV via EXCEL using COM
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
What you want is an "object viewer".

The Windows SDKs come with one called OLEView.exe. This will allow you to browse the objects and see the enumerations, methods and properties.

Only those objects which support COM automation are useable from KiXtart. This is because these objects have an extra layer of abstraction that allows the object to be used in scripting languages.

While you're at it, also get hold of the WMI tools, which includes a WMI Object Browser.

Top
#112011 - 2004-01-28 04:44 PM Re: Creating .XLS from .CSV via EXCEL using COM
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
I wonder how your code is look alike... I am busy with the same thing and maybe you can give me a good start the resolve my problem by posting your code...

Edited by Co (2004-01-28 08:49 PM)
_________________________
Co


Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.059 seconds in which 0.031 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org