Page 1 of 1
Crear un libro en excel
Posted: Thu Mar 04, 2010 11:52 pm
by jucar_es
Buenas tardes a todos
hasta ahora e podido desde HMG crear hojas de excel sin ningun problema, ahora necito poder crear varias hojas dentro de mismo archivo,.
ALGUIEN PUEDE AYUDARME?
Re: Crear un libro en excel
Posted: Tue Mar 09, 2010 9:10 am
by Alex Gustow
jucar_es wrote:Buenas tardes a todos
hasta ahora e podido desde HMG crear hojas de excel sin ningun problema, ahora necito poder crear varias hojas dentro de mismo archivo,.
ALGUIEN PUEDE AYUDARME?
(Goglish = Google + English

)
jucar_es wrote:Good afternoon everyone
so far and have since HMG create Excel spreadsheets without any problem, now little hands to create multiple sheets within same file.
CAN ANYONE HELP ME?
Hi, jucar_es!
As I think, it's easy (but maybe I'm wrong? correct me, guys):
Code: Select all
oExcel := TOleAuto():New( "Excel.Application" )
oExcel:Sheets:Add() // add one sheet
oExcel:Sheets:Add() // add one more
... etc
I didn't test this sample - only run Excel, run "Service"-"Macros"-"Record" [named it "MyMacros1"]; do what I need; view ("Service"-"Macros"-"Macroses" [Alt+F8] "Edit" MyMacros1) what Excel writes to macro-sub; copy from Excel's Visual Basic window what I need; past to my prog; change "."-s (dots) to ":"-s... something like that...
Maybe it helps you.
Re: Crear un libro en excel
Posted: Tue Mar 09, 2010 4:53 pm
by joposadas
Para crear hojas dentro de un libro excel usa esto
oExcel:Sheets("Hoja1"):Name := "Total general"
oExcel:Sheets("Hoja2"):Name := "Total por tipo de pago"
oExcel:Sheets("Hoja3"):Name := "Detalle de las ventas"
Si quieres posicionarte en una hoja entonces usa esto:
oExcel:Sheets("Total general"):Select()
oHoja := oExcel:Get( "ActiveSheet" )