Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel with Multiple Worksheet
Message
From
11/01/2006 05:43:09
 
 
To
10/01/2006 20:44:40
General information
Forum:
Visual FoxPro
Category:
Third party products
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01085026
Message ID:
01085522
Views:
41
oSheet is NOT a property of the excel object.

I suggest you get the book 'Microsoft Office Automation' by Tamar Granor from www.Hentzenwerke.com

Peter


>>>Does it work now?
>>>
>>>Three comments:
>>>
>>>1. You don't need GO TOP before a SCAN.
>>>
>>>2. It helps if you put computer code (in the UT) between the codes < pre > and < /pre > (without the spaces). In this case, spaces are maintained; the result is more readable.
>>>
>>>3. If you transfer lots of data, it is very slow to insert each cell individually. In this case, you might use copy & paste, or copy to DBF or to text delimited or something, and insert lots of records into Excel with a single command. Of course, also using Automation.
>>>
>>>>Hi Hilmar,
>>>>
>>>>
>>>> This is my code,
>>>>
>>>>ole = CreateObject("Excel.Application")
>>>>With ole
>>>> nrow=7
>>>> nrecno=1
>>>> Select cur_inv
>>
>>>> Go Top
>>>> SCAN
>>>> .Cells(nrow,1).Value=cur_inv.invdate
>>>> .Cells(nrow,2).Value=cur_inv.icsno
>>>> .Cells(nrow,3).Value=cur_inv.loctid
>>>> nrow = nrow+1
>>>> nrecno = nrecno+1
>>>> IF nrecno=60 THEN
>>>> nrow=7
>>>> nrecno=1
>>>>
>>>> with This
>>>> local loWorkbook
>>>> loWorkbook = .oSheet.Parent
>>>> .nActiveSheet = .nActiveSheet + 1
>>>> if This.nActiveSheet > loWorkbook.Sheets.Count
>>>> loWorkbook.Sheets.Add(NULL, loWorkbook.Sheets(loWorkbook.Sheets.Count))
>>>> .oSheet = loWorkbook.ActiveSheet
>>>> else
>>>> .oSheet = loWorkbook.Sheets(This.nActiveSheet)
>>>> endif
>>>> .nRow = 1
>>>> .nCol = 1
>>>> endwith
>>>>
>>>>
>>>> ENDIF
>>>> SELECT cur_inv
>>>> ENDSCAN
>>>>
>>>>ENDWITH
>>
>
>Hi Hilmar,
>
> it gives me the same result," Unknown Member oSheet".
>
>
>        ole = CreateObject("Excel.Application")
>        With ole
>         nrow=7
>         nrecno=1
>           Select cur_inv
>            SCAN
>		.Cells(nrow,1).Value=cur_inv.invdate
>		.Cells(nrow,2).Value=cur_inv.icsno
>		.Cells(nrow,3).Value=cur_inv.loctid
>		 nrow = nrow+1
>               nrecno = nrecno+1
>		   IF nrecno=60 THEN
>		      nrow=7
>		      nrecno=1
>				
>		      with This
>			    local loWorkbook
>			    loWorkbook = .oSheet.Parent
>			    .nActiveSheet = .nActiveSheet + 1
>			if This.nActiveSheet > loWorkbook.Sheets.Count
>			    loWorkbook.Sheets.Add(NULL, loWorkbook.Sheets(loWorkbook.Sheets.Count))
>				.oSheet = loWorkbook.ActiveSheet
>			else
>				.oSheet = loWorkbook.Sheets(This.nActiveSheet)
>			endif
>				.nRow = 1
>				.nCol = 1
>		endwith
>			
>	ENDIF
>	SELECT cur_inv
>	ENDSCAN
>		
>EndWith
>
Peter Cortiel
Previous
Reply
Map
View

Click here to load this message in the networking platform