Expert Software Company : News

duminică, 28 octombrie 2012

Copiere rapida a unui tabel in Excel


Function FastExcelCopy (tcTable As String, tcXlsFile As String, tlOpen) As VOID HelpString 'Copieaza o tabela in Excel'
If Not Used(TcTable)
MessageBox("Eroare: Tabela nu este deschisa !", 16, "Eroare")
Return
EndIf
Local lnWorkArea
lnWorkArea = Select()

Select (tcTable)
Local lcTmpFile
lcTmpFile = GetEnv("TEMP")+"" + Sys(2015) + ".Tmp"
Copy To (lcTmpFile) Delimited With Tab
_Cliptext = FileToStr(lcTmpFile)

oExcel= Createobject("Excel.Application")
With oExcel
.DisplayAlerts = .F.
.Workbooks.Add()
    .Range("A1").PasteSpecial
EndWith
If PCount()>1
oExcel.Workbooks(1).SaveAs(tcXlsFile)
EndIf
If Not tlOpen
oExcel.Quit
oExcel= .Null.
Release oExcel
EndIf
Select (lnWorkArea)
EndFunc

Niciun comentariu:

Trimiteți un comentariu