The function below
opens excel
creates a new workbook
resizes some cells to square
draws some silly block animation
saves and closes the workbook
Just another demo of what Alpha's ole methods can do.
What can I say, it is Friday!
opens excel
creates a new workbook
resizes some cells to square
draws some silly block animation
saves and closes the workbook
Just another demo of what Alpha's ole methods can do.
What can I say, it is Friday!
Code:
'Date Created: 09-Jan-2003 08:35:07 PM 'Last Updated: 17-Apr-2007 08:36:56 AM 'Created By : original framework by John Magno - http://www.JohnMagno.com 'Updated By : FUNCTION ex_demo AS C (excelname AS C) 'usage is like...... ex_demo("C:\demo.xls") Dim xlApp as p dim myCell as c xlApp = ole.create("Excel.Application") 'xlApp.Workbooks.Open(excelname) xlApp.Workbooks.Add() xlApp.Columns("A:BZ").Select() xlApp.Selection.ColumnWidth = 2 xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 xlApp.Visible = .T. 'comment this line out if you don't want to see Excel , which wouldn't make sense in this function xlApp.Range("A30").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 sleep(1) xlApp.Range("B28").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 sleep(1) xlApp.Range("C26").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 sleep(1) xlApp.Range("D24").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("A30").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("E22").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 sleep(1) xlApp.Range("B28").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = -4142 xlApp.Range("G20").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("C26").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = -4142 sleep(1) xlApp.Range("I19").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("D24").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = -4142 sleep(1) xlApp.Range("K19").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("E22").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = -4142 sleep(1) xlApp.Range("M21").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("G20").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("I19").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("K19").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("M21").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("L20:N22").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 sleep(.5) xlApp.Range("L20:N22").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 sleep(1) xlApp.Range("K19,O19,O23,K23").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("J18,P18,P24,J24,K21,M19,O21,M23").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("I17,Q17,Q25,I25,J21,M18,P21,M24").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("H16,R16,R26,H26,I21,M17,Q21,M25").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("G15,S15,S27,G27,H21,M16,R21,M26").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("F14,T14,T28,F28,G21,M15,S21,M27").Select() xlApp.Selection.Interior.ColorIndex = 3 xlApp.Selection.Interior.Pattern = 1 sleep(2) xlApp.Range("L20:N22").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("K19,O19,O23,K23").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("J18,P18,P24,J24,K21,M19,O21,M23").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("I17,Q17,Q25,I25,J21,M18,P21,M24").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("H16,R16,R26,H26,I21,M17,Q21,M25").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("G15,S15,S27,G27,H21,M16,R21,M26").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("F14,T14,T28,F28,G21,M15,S21,M27").Select() xlApp.Selection.Interior.ColorIndex = 6 xlApp.Selection.Interior.Pattern = 1 Sleep(1) xlApp.Range("L20:N22").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("K19,O19,O23,K23").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("J18,P18,P24,J24,K21,M19,O21,M23").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("I17,Q17,Q25,I25,J21,M18,P21,M24").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("H16,R16,R26,H26,I21,M17,Q21,M25").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("G15,S15,S27,G27,H21,M16,R21,M26").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 Sleep(.5) xlApp.Range("F14,T14,T28,F28,G21,M15,S21,M27").Select() xlApp.Selection.Interior.ColorIndex = -4142 xlApp.Selection.Interior.Pattern = 1 xlApp.Range("A1").Select() Sleep(1) xlapp.DisplayAlerts = .F. xlApp.ActiveWorkbook.SaveAs(excelname,-4143) '33 is a constant for Excel 4.0, dbf4 is 11 xlApp.Workbooks.Close() xlapp.DisplayAlerts = .T. xlApp.Quit() END FUNCTION
Comment