Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Importing a spreadsheet-like HTML file
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01155024
Message ID:
01155583
Views:
30
>Hi again BB
>
>It's your Wednesday afternoon virus now :-)
>
>Just trying to wade my way through the Basic code from my recorded macro.
>
>
>loExcel = CREATEOBJECT([Excel.Application])
>Wait WINDOW "Opening HTML File ..." NOWAIT NOCLEAR
>With loExcel
>  .Workbooks.Open( "R:\OPDATA\Essex\SM_Coaches\APR06\sm coaches disk.htm")
>  Wait WINDOW "Saving as Excel Spreadsheet ..." NOWAIT NOCLEAR
>  .ActiveWorkBook.SaveAs("Test.XLS", xlNormal)
>  Wait CLEAR
>* For Now>	  With .ActiveSheet
>    .Rows("1:4").Select
>    .selection.
>* For Now>	    .Selection.Delete Shift=xlUp
>    .Selection.FormatConditions.Delete
>    .Columns("C:C").Select
>* For Now>	    .Selection.Delete Shift=xlToLeft
>    .Selection.FormatConditions.Delete
>
>In the above lines (note I've commented out the With .activesheet line - so now I'm getting further).
>I can't seem to get Intellisense to react to my code and so am flying pretty blind.
>
>When I issue the ".ActiveWorkBook.SaveAs("Test.XLS", xlNormal)" I get an "OLE dispatch error - cannot access Test.xls"
>
>When I issue ".Selection.Delete Shift=xlToLeft" I get "Syntax error" - obviously, as I don't know the translation.
>
>Same with ".Selection.Insert Shift=xlToRight"
>
>I wonder if you could put me right on the syntax (beware, I'll probably be back for more once I've got thses simpler commands out of the way).
>
>BTW, all these actions are taking place "in the dark" so to speak, as no visible file is produced - no spreadsheet, either in HTML or XLS form.
>
>Thanks
>
>Terry


Sorry for delay, but I was on my way home. Try this:
#define xlUp     -4162
#define xlToLeft -4159
#define xlNormal -4143


** Put this so Intellisense to be activated
LOCAL loExcel AS Excel.Application

loExcel = CREATEOBJECT([Excel.Application])


*** If you want to see what happens add this line
loExcel.Visible = .t.

Wait WINDOW "Opening HTML File ..." NOWAIT NOCLEAR 
loExcel.Workbooks.Open( "R:\OPDATA\Essex\SM_Coaches\APR06\sm coaches disk.htm")

*** Turn of all warnings
loExcel.DisplayAlerts = 0

**** Select and delete rows from one to 4
loExcel.Range([1:4]).Delete(xlUp)

**** Select and delete Column C
loExcel.Range([C:C]).Delete(xlToLeft)

*** Save the file AFTER you made all changes
loExcel.ActiveWorkBook.SaveAs("Test.XLS", xlNormal)

*** Close the file. You leave it opened, that is why you get that error message
*** If you call Task manager you will see several EXCELs running :-)
loExcel.ActiveWorkBook.Close()

*** QUIT the Excel
loExcel.Quit()

loExcel = NULL
RELEASE loExcel

*** AND CLEAR WAIT WINDOW :-))))))) 
WAIT CLEAR
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform