Author | Topic: xBase Syntax for Excel | |
---|---|---|
Fransm | xBase Syntax for Excel on Tue, 11 Mar 2008 08:23:45 +0200 Hi All, I am trying to add a worksheet after the last worksheet. Using oWorkbook:worksheets():Add() gives me a new worksheet. How do I code so that the workheet is added after the last worksheet. Any help would be greatly appreciated. Regards, Frans | |
Peter Alderliesten | Re: xBase Syntax for Excel on Fri, 04 Apr 2008 10:07:50 +0200 Frans: > I am trying to add a worksheet after the last worksheet. > Using oWorkbook:worksheets():Add() gives me a new worksheet. How do I code > so that the workheet is added > after the last worksheet. This is what I found in the help (it's translated, because I only have the Dutch version): Application.Sheets The Sheets collection can contain Chart- or Worksheet-objects. With the method Add you can create and add a new Worksheet to the Sheets collection. Sheets.Add type:=xlChart, count:=2, after:=Sheets(2) Regards, Peter | |
Fransm | Re: xBase Syntax for Excel on Fri, 04 Apr 2008 16:32:21 +0200 Hi Peter, Thanks for the reply. According the docs I need to execute the following VB command: This example adds a new worksheet after the last worksheet in the active workbook. Worksheets.Add.Move after:=Worksheets(Worksheets.Count) How Do I code this in xbase so that the compiler does not complain ?This then raises some more questions. How to code other VB commands ? Where can Iget documentation on converting VB commands to xBase, or is it a case of suck thumband hope that you hit pay dirt ?regards,Frans"Peter Alderliesten" <p.alderliesten@emergo-systems.nl> wrote in message news:74me394q5ppa.1rxw9vngi0dx5.dlg@40tude.net... > Frans: > > > I am trying to add a worksheet after the last worksheet. > > Using oWorkbook:worksheets():Add() gives me a new worksheet. How do I code > > so that the workheet is added > > after the last worksheet. > > This is what I found in the help (it's translated, because I only have the > Dutch version): > > Application.Sheets > > The Sheets collection can contain Chart- or Worksheet-objects. > With the method Add you can create and add a new Worksheet to the Sheets > collection. > > Sheets.Add type:=xlChart, count:=2, after:=Sheets(2) > > Regards, > Peter | |
Ron Pinkas | Re: xBase Syntax for Excel on Fri, 04 Apr 2008 09:29:46 -0700 Frans, > According the docs I need to execute the following VB command: > > This example adds a new worksheet after the last worksheet in the active > workbook. > Worksheets.Add.Move after:=Worksheets(Worksheets.Count) > How Do I code this in xbase so that the compiler does not complain ? Try: Worksheets:Add:Move( , Worksheets( Worksheets:Count ) ) The Move method is documented as follows: Move( [Before], [After] ) > This > then raises some more questions. How to code other VB commands ? In VB: Worksheets.Add.Move after=Worksheets(Worksheets.Count) means that the Move method will receive only 1 argument, but it will resolve it BYNAME (after), vs. position. > Where can > Iget documentation on converting VB commands to xBase, or is it a case of > suck thumband hope that you hit pay dirt ? I don't know of such docs, basically you'll need to be familiar with both languages, so that you can calculate the needed translation. Ron | |
Ronald van Veelen | Re: xBase Syntax for Excel on Mon, 07 Apr 2008 09:01:06 +0200 Op Fri, 04 Apr 2008 09:29:46 -0700 schreef Ron Pinkas: > Frans, > >> According the docs I need to execute the following VB command: >> >> This example adds a new worksheet after the last worksheet in the active >> workbook. >> Worksheets.Add.Move after:=Worksheets(Worksheets.Count) >> How Do I code this in xbase so that the compiler does not complain ? > > Try: > > Worksheets:Add:Move( , Worksheets( Worksheets:Count ) ) > > The Move method is documented as follows: > > Move( [Before], [After] ) > >> This >> then raises some more questions. How to code other VB commands ? > > In VB: > > Worksheets.Add.Move after=Worksheets(Worksheets.Count) > > means that the Move method will receive only 1 argument, but it will resolve > it BYNAME (after), vs. position. > >> Where can >> Iget documentation on converting VB commands to xBase, or is it a case of >> suck thumband hope that you hit pay dirt ? > > I don't know of such docs, basically you'll need to be familiar with both > languages, so that you can calculate the needed translation. > > Ron In Excel press alt+F11, the vb editor will open. Now press F2. There you'll find an index of all excel classes with there methods and properties. Good luck! | |
Fransm | Re: xBase Syntax for Excel on Mon, 07 Apr 2008 10:26:33 +0200 Hi Ron and Peter, Thanks for the help. Got it working. regards frans | |
Hubert Brandel | Re: xBase Syntax for Excel on Fri, 11 Apr 2008 14:00:17 +0200 Fransm schrieb: > Hi Ron and Peter, > > Thanks for the help. Got it working. > > regards > > frans > > Hi, i have the same problem, could you please show me the right Syntax: This will not work here: oBook:worksheets:add:move(,oBook:worksheets:count) in the example above is a function worksheets() used, i do not have this function, maybe it is a .NET one. Here is my errormessage on my try ------------------------------------------------------------------------------ FEHLERPROTOKOLL von "D:\Alaska\ALASKA.190\XPPW32\SOURCE\samples\activex\msexcel\excel2.exe" Datum: 11.04.2008 13:33:12 Xbase++ Version : Xbase++ (R) Version 1.90.331 Betriebssystem : Windows 2000 05.00 Build 02195 Service Pack 4 ------------------------------------------------------------------------------ oError:args : -> VALTYPE: C VALUE: move -> VALTYPE: U VALUE: NIL -> VALTYPE: N VALUE: 4 oError:canDefault : J oError:canRetry : N oError:canSubstitute: J oError:cargo : NIL oError:description : Die Move-Methode des Worksheet-Objektes konnte nicht ausgefhrt werden. oError:filename : NIL oError:genCode : NIL oError:operation : move oError:osCode : -2146827284 oError:severity : 2 oError:subCode : 6500 oError:subSystem : Automation oError:thread : 1 oError:tries : NIL ------------------------------------------------------------------------------ CALLSTACK: ------------------------------------------------------------------------------ Called from MAIN(102) ADD does ADD a neu worksheet at front, but move can't put it to end. The direct way: oBook:worksheets:add(,oBook:worksheets:count) will fail here too. Bye Hubert ---------------- Ich empfehle: www.xbaseforum.de (in deutsch) Homepage: German - www.familie-brandel.de/index.htm English - www.familie-brandel.de/index_e.htm -- ---------------- Ich empfehle: www.xbaseforum.de (in deutsch) Homepage: German - www.familie-brandel.de/index.htm English - www.familie-brandel.de/index_e.htm | |
Fransm | Re: xBase Syntax for Excel on Fri, 11 Apr 2008 14:53:56 +0200 Hi Hubert, Try the following: oBook:worksheets:add:move(,oBook:worksheets(oBook:Worksheets:Count())) regards frans | |
Hubert Brandel | Re: xBase Syntax for Excel on Fri, 11 Apr 2008 19:27:21 +0200 Fransm schrieb: > Hi Hubert, > > Try the following: > > oBook:worksheets:add:move(,oBook:worksheets(oBook:Worksheets:Count())) > > regards > > frans > > Hi, thanks a lot. To add it as last worksheet this will do it direct: oBook:worksheets:add(,oBook:worksheets(oBook:Worksheets:Count())) this will not work, so a VARIANT seams not to be a number : oBook:worksheets:add(,3) This will add and move ... oBook:worksheets:add:move(,oBook:worksheets(oBook:Worksheets:Count())) Bye Hubert ---------------- Ich empfehle: www.xbaseforum.de (in deutsch) Homepage: German - www.familie-brandel.de/index.htm English - www.familie-brandel.de/index_e.htm | |
Hubert Brandel | Re: xBase Syntax for Excel on Fri, 11 Apr 2008 19:57:08 +0200 Now I understand, the ADD() and move() does not expect the NUMBER the expect the sheet object itself. I have the active sheet stored in oSheet, so to add the next sheet behind this sheet, its so easy: oBook:worksheets:add(,oSheet) Thanks to all for the hints. Bye Hubert ---------------- Ich empfehle: www.xbaseforum.de (in deutsch) Homepage: German - www.familie-brandel.de/index.htm English - www.familie-brandel.de/index_e.htm | |
Klaus Overhage | Re: xBase Syntax for Excel on Fri, 11 Apr 2008 16:29:34 +0200 Hubert, maybe you must do nLast := oBook:Worksheets(:Coun() oBook:Worksheets(nlast):Select() oBook:Worksheets():Add() Hubert Brandel schrieb: > Fransm schrieb: >> Hi Ron and Peter, >> >> Thanks for the help. Got it working. >> >> regards >> >> frans >> >> > > Hi, > > i have the same problem, could you please show me the right Syntax: > > This will not work here: > > oBook:worksheets:add:move(,oBook:worksheets:count) > > in the example above is a function worksheets() used, i do not have this > function, maybe it is a .NET one. > Here is my errormessage on my try > > > ------------------------------------------------------------------------------ > > FEHLERPROTOKOLL von > "D:\Alaska\ALASKA.190\XPPW32\SOURCE\samples\activex\msexcel\excel2.exe" > Datum: 11.04.2008 13:33:12 > > Xbase++ Version : Xbase++ (R) Version 1.90.331 > Betriebssystem : Windows 2000 05.00 Build 02195 Service Pack 4 > ------------------------------------------------------------------------------ > > oError:args : > -> VALTYPE: C VALUE: move > -> VALTYPE: U VALUE: NIL > -> VALTYPE: N VALUE: 4 > oError:canDefault : J > oError:canRetry : N > oError:canSubstitute: J > oError:cargo : NIL > oError:description : Die Move-Methode des Worksheet-Objektes konnte > nicht ausgefhrt werden. > oError:filename : NIL > oError:genCode : NIL > oError:operation : move > oError:osCode : -2146827284 > oError:severity : 2 > oError:subCode : 6500 > oError:subSystem : Automation > oError:thread : 1 > oError:tries : NIL > ------------------------------------------------------------------------------ > > CALLSTACK: > ------------------------------------------------------------------------------ > > > Called from MAIN(102) > > ADD does ADD a neu worksheet at front, but move can't put it to end. > The direct way: > > oBook:worksheets:add(,oBook:worksheets:count) > > will fail here too. > > Bye > Hubert > |