Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fast
Message
De
05/11/2009 01:41:27
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Fast
Divers
Thread ID:
01432885
Message ID:
01433286
Vues:
65
thank you,
i try as below , at line endtry i get error message Unhandled Structured Exception
errorno:1
message:file'log_error.prg'dose not exist
user value :
CLOSE all
USE koko

local lnMax
lnMax = 18
local array laXLSFiles[lnMax]

FOR i=1 TO lnMax
   COPY FOR numbers=i TO ("sheet" + TRANSFORM(i)) TYPE XL5 
   laXLSFiles[m.i] = sys(5) + curdir() + 'sheet' + transform(m.i) + 'xls' 
ENDFOR

=CombineExcelFiles(laXLSFiles, 'c:\dept\amman.xls')

function CombineExcelFiles (taXLSFiles, tcDestination, tlDeleteOriginal)
external array taXLSFiles
local loExcel as Excel.application, ;
	loWorkBook as Excel.Worksbook, ;
	loWorkSheet , ;
	lnCounter, lcWorkSheetCaption, lcError, ;
	lcValidChars

lcError = ""

try
	lcValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
	loExcel = newobject("Excel.Application")
	with loExcel
		.ScreenUpdating = .f.
		.DisplayAlerts = .f.
		.WorkBooks.add()
		lnCounter = 0

** Delete all existing worksheets except 1
		for each loWorkSheet in .WorkBooks(1).WorkSheets
			lnCounter = m.lnCounter + 1
			if m.lnCounter > 1
				loWorkSheet.delete
			endif
		endfor

		for lnCounter = 1 to alen(taXLSFiles,1)
			if file(taXLSFiles[m.lnCounter])
				lcWorkSheetCaption = juststem(taXLSFiles[m.lnCounter])
				loWorkBook = .WorkBooks.open(taXLSFiles[m.lnCounter])
				loWorkBook.WorkSheets(1).copy(null, ;
					.WorkBooks(1).WorkSheets(.WorkBooks(1).WorkSheets.count))
				.WorkBooks(1).ActiveSheet.name = ;
					right(alltrim(chrtran(m.lcWorkSheetCaption, ;
					chrtran(m.lcWorkSheetCaption,m.lcValidChars,"")," ")), 31) &&loWorkBook.Name
				loWorkBook.close(.f.) && Don't save changes
				if m.tlDeleteOriginal
					erase (taXLSFiles[m.lnCounter])
				endif
			endif
		endfor
** Remove the first original sheet from (Sheet1)
		.WorkBooks(1).WorkSheets(1).delete

		.WorkBooks(1).saveas(m.tcDestination)
		.ScreenUpdating = .t.
		.DisplayAlerts = .t.
	endwith

catch to loError
	lcError = Log_Error(m.loError)
finally
	if vartype(m.loExcel) = 'O'
		with loExcel
			.ScreenUpdating = .t.
			.DisplayAlerts = .t.
			.quit()
		endwith
	endif
endtry

return m.lcError
endfunc
>Try
>
>local lnMax
>lnMax = 18
>local array laXLSFiles[lnMax]
>
>FOR i=1 TO lnMax
>   COPY FOR numbers=i TO ("sheet" + TRANSFORM(i)) TYPE XL5 
>   laXLSFiles[m.i] = sys(5) + curdir() + 'sheet' + transform(m.i) + 'xls' 
>ENDFOR
>
>=CombineExcelFiles(laXLSFiles, 'c:\dept\amman.xls')
>
>
>>
>>See this function
>>
>>function CombineExcelFiles (taXLSFiles, tcDestination, tlDeleteOriginal)
>>external array taXLSFiles
>>local loExcel as Excel.application, ;
>>	loWorkBook as Excel.Worksbook, ;
>>	loWorkSheet , ;
>>	lnCounter, lcWorkSheetCaption, lcError, ;
>>	lcValidChars
>>
>>lcError = ""
>>
>>try
>>	lcValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
>>	loExcel = newobject("Excel.Application")
>>	with loExcel
>>		.ScreenUpdating = .f.
>>		.DisplayAlerts = .f.
>>		.WorkBooks.add()
>>		lnCounter = 0
>>
>>** Delete all existing worksheets except 1
>>		for each loWorkSheet in .WorkBooks(1).WorkSheets
>>			lnCounter = m.lnCounter + 1
>>			if m.lnCounter > 1
>>				loWorkSheet.delete
>>			endif
>>		endfor
>>
>>		for lnCounter = 1 to alen(taXLSFiles,1)
>>			if file(taXLSFiles[m.lnCounter])
>>				lcWorkSheetCaption = juststem(taXLSFiles[m.lnCounter])
>>				loWorkBook = .WorkBooks.open(taXLSFiles[m.lnCounter])
>>				loWorkBook.WorkSheets(1).copy(null, ;
>>					.WorkBooks(1).WorkSheets(.WorkBooks(1).WorkSheets.count))
>>				.WorkBooks(1).ActiveSheet.name = ;
>>					right(alltrim(chrtran(m.lcWorkSheetCaption, ;
>>					chrtran(m.lcWorkSheetCaption,m.lcValidChars,"")," ")), 31) &&loWorkBook.Name
>>				loWorkBook.close(.f.) && Don't save changes
>>				if m.tlDeleteOriginal
>>					erase (taXLSFiles[m.lnCounter])
>>				endif
>>			endif
>>		endfor
>>** Remove the first original sheet from (Sheet1)
>>		.WorkBooks(1).WorkSheets(1).delete
>>
>>		.WorkBooks(1).saveas(m.tcDestination)
>>		.ScreenUpdating = .t.
>>		.DisplayAlerts = .t.
>>	endwith
>>
>>catch to loError
>>	lcError = Log_Error(m.loError)
>>finally
>>	if vartype(m.loExcel) = 'O'
>>		with loExcel
>>			.ScreenUpdating = .t.
>>			.DisplayAlerts = .t.
>>			.quit()
>>		endwith
>>	endif
>>endtry
>>
>>return m.lcError
>>endfunc
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform