Guys, by default Excel creates 3 empty sheets, how do I add 2 more to the end of them so I end with Sheet1, Sheet2, Sheet3, Sheet4 and Sheet5 in sequence?
TIA
How to add append new Sheet in Excel?
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: How to add append new Sheet in Excel?
A sample:
EMG
Code: Select all | Expand
FUNCTION MAIN()
LOCAL oExcel := CREATEOBJECT( "Excel.Application" )
LOCAL oSheet
oExcel:Workbooks:Add()
oSheet = oExcel:Sheets:Add( oExcel:Sheets[ oExcel:Sheets:Count ] )
oExcel:Sheets[ oExcel:Sheets:Count ]:Move( oSheet )
oSheet:Name = "Added"
oExcel:Visible = .T.
RETURN NIL
EMG
Re: How to add append new Sheet in Excel?
Thanks for the prompt response Enrico. Your solution has helped me.
Out of curiosity, can't we pass a parameter to :add() to indicate where the new sheet should be added?
Out of curiosity, can't we pass a parameter to :add() to indicate where the new sheet should be added?
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
BCC5.82/BCC7.3
xHarbour/Harbour
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: How to add append new Sheet in Excel?
Based on the link you've given (thanks!) and some tutorial here I try coding this way,
Seems to generate runtime error on my PC though. Couldn't get it to work
Code: Select all | Expand
oExcel:Sheets:Add(, oExcel:Sheets[ oExcel:Sheets:Count() ], 2 )
Seems to generate runtime error on my PC though. Couldn't get it to work
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
BCC5.82/BCC7.3
xHarbour/Harbour
Re: How to add append new Sheet in Excel?
Found an old post of yours Enrico - https://groups.google.com/forum/?fromgr ... %5B1-25%5D
Is OleDefaultArg() available in both Harbour and xHarbour?
Is OleDefaultArg() available in both Harbour and xHarbour?
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
BCC5.82/BCC7.3
xHarbour/Harbour
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact: