Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fast
Message
 
 
To
09/11/2009 01:52:30
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Fast
Miscellaneous
Thread ID:
01432885
Message ID:
01433811
Views:
46
What is your OS and Office version ? I believe we did have some problems similar to this, but I forgot our solution - it could be that this is not the latest code, but I don't have an access to the very latest code anyway.

>thank you, it works i get all sheets at myfolder not inside book1 as book1.sheet1,sheet2.......sheet18
>
>i need to insert the 18 sheets at book1(amman) as amman.sheet1 to ...amman.sheet18
>
>=CombineExcelFiles(laXLSFiles, 'c:\dept\amman.xls')&& not work
>
>at the end of operation i see message ..do you want to save the change you made to 'book1'?>
>
>CLOSE all
>#define CRLF chr(13) + chr(10)
>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')&& not work 
>
>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
>
>
>*********************
>function Log_Error
>lparameters toError
>local lcError, lcVars
>
>lcError = [Error: ] + transform(m.toError.errorno) + CRLF + ;
>	[LineNo: ] + transform(m.toError.lineno) + CRLF +  ;
>	[Message: ] + m.toError.message  + CRLF +  ;
>	[Procedure: ] + m.toError.procedure + CRLF +  ;
>	[Details: ] + m.toError.details  + CRLF + ;
>	[StackLevel: ] + transform(m.toError.stacklevel) + ;
>	iif(_vfp.startmode = 0, CRLF + [LineContents: ] + m.toError.linecontents, '')
>
>
>return m.lcError
>*The three chief virtues of a programmer 
>
>>Add at the very top of your program
>>
>>#define CRLF chr(13) + chr(10)
>>
>>
>>>thank you ,
>>>i try it ,
>>>i get another error message at line endtry
>>>Unhandled Structured Exception
>>>errorNo:12
>>>Message:variable'CRLF' is not found
>>>user value:
>>>
>>>can i sent the table, it is small table just 38 records with 6 fields at your Ps.email, if you don't mind to sent your ps email as
>>>private message.
>>>
>>>thanks
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform