
Need help passing arguments to a COM method...
Thank you both for your answers. I tried to specify all the arguments listed
in my book, but alas I kept getting the "workbook method failed message".
The situation is complicated since some of the arguments to OpenText are
only appropriate if certain other arguments are specified, plus I think my
book may be wrong about the exact arguments and/or the order the must be
specified. I'll try to access VBA help from my version of Excel (2000 / 9.0)
to verify the arguments.
In the mean time, I've gone around the problem by using the OpenTextFile
method of the scripting.filesystem object and then putting the info into an
array mad then putting that into my spreadsheet. It's slower, but works
well.
Thanks again,
Robert
Quote:
> No. You need to get rid of the "filename :=" part entirely. This is what's
> known as a named argument, which is not supported in vbscript. This is all
> you need:
> xlWb.OpenText "H:\license\licensefile"
> The drawback to this is that ALL arguments must be passed, IN ORDER. Look
up
> the OpenText method in VBA Help and make sure you provide all the listed
> arguments.
> Bob Barrows
> > Torgeir,
> > Thank you, this is good stuff! But which of these examples shows how I
> > should re-write the named arguments? Because I don't know how to rewrite
> > them... And I don't see the answer in the links you provided.
> > I think you mean I should change:
> > xlWb.OpenText _
> > fileName:="H:\license\licensefile"
> > ...
> > To:
> > xlWb.OpenText _
> > xlWb.OpenText.fileName="H:\license\licensefile"
> > Am I getting warmer?
> > Thank you very much,
> > Robert Stober
> > > > I've been trying (and failing) for the last several hours to call an
> > Excel
> > > > method from my vbs script. The trouble is that the arguments are
> rather
> > > > complicated. Here's a snippet of the Excel VBA code that I'm trying
to
> > move
> > > > the into my vbs script (this code works)
> > > Hi
> > > VBscript doesn't support named argument syntax (e.g.,
> > ArgName:="argvalue"), you
> > > have to rewrite this.
> > > More on differences between VBA and VBS here:
> > > Subject: Re: insert toc in word .doc via script
> > > http://groups.google.com/groups?selm=uZwIMevaCHA.1332%40tkmsftngp11
> > > Some examples on using the Excel object from VBScript:
> > > Read from Microsoft Excel
> > > http://www.rlmueller.net/Read%20from%20Excel.htm
> > > Write to Microsoft Excel
> > > http://www.rlmueller.net/Write%20to%20Excel.htm
> > > Automate Excel In Vbscript...
http://cwashington.netreach.net/depo/view.asp?Index=142&ScriptType=vb...
Quote:
> > > Import task from Outlook in order to create a Status report in an
Excel
> > > Spreadsheet
http://cwashington.netreach.net/depo/view.asp?Index=510&ScriptType=vb...
Quote:
> > > Use Excel To Generate Charts...
http://cwashington.netreach.net/depo/view.asp?Index=300&ScriptType=vb...
Quote:
> > > Google newsgroup search in the microsoft.public.scripting.vbscript
group
http://groups.google.com/groups?as_epq=excel%20application&safe=image...
Quote:
> > O-8859-1&as_ugroup=microsoft.public.scripting.vbscript&lr=&hl=en
> > > Google newsgroup search in the microsoft.public.scripting.wsh group
http://groups.google.com/groups?as_epq=excel%20application&safe=image...
Quote:
> > O-8859-1&as_ugroup=microsoft.public.scripting.wsh&lr=&hl=en
> > > --
> > > torgeir
> > > Microsoft MVP Scripting and WMI, Porsgrunn Norway
> > > Administration scripting examples and an ONLINE version of the 1328
page
> > > Scripting Guide: http://www.microsoft.com/technet/scriptcenter