Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations danielledunham on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

excel automation column problem 2

Status
Not open for further replies.

borsker

Programmer
Joined
Jul 24, 2002
Messages
147
Location
US
I am trying to use an existing excel sheet that comes in the same way every time. I usually import the data into foxpro but i believe the currency column is turning the data into a date even though it is imported as a character. To make a long story short, here is the code i am trying to use, however i am very new to this and i am sure i am doing something wrong. I am getting this error on the last line of the code and i am not sure why. "xlSheet is not an object"

tmpsheet = getOBJECT('c:\ftp_over\matrix.xls')
oExcel = tmpsheet.APPLICATION
oExcel.ReferenceStyle = 1 && Ensure Columns in A-B Format instead of 1-2 Format

mcStrtColRow = 'C1'
mcEndColRow = 'C30'

xlSheet = oExcel.activesheet


xlSheet.RANGE[mcStrtColRow,mcEndColRow].EntireColumn.NumberFormat = "@"


thanks for any help
 
here is the code, let me know if you see any problems with it.


mcInFile = "s:\temp\matrix.xls" && Or whatever input File
mcInName = JUSTFNAME(mcInFile)
mcOutDBF = "s:\temp\matrix88.dbf" && Or whatever output File

tmpsheet = CREATEOBJECT('excel.application')
oExcel = tmpsheet.APPLICATION
oExcel.Workbooks.CLOSE

oExcel.workbooks.OPEN(mcInFile)
oExcel.WINDOWS(mcInName).ACTIVATE

xlBook = oExcel.ActiveWorkbook
oExcel.ReferenceStyle = 1
xlSheet = oExcel.ActiveSheet

xlSheet.rows("1:4").delete
xlSheet.range("A:I").NumberFormat ="@"


xlsheet.rows("2:2").insert
xlsheet.range("A2:I2")="xxxx"


xlSheet.SAVEAS (mcOutDBF, 11, 0)


* --- Close the Worksheet ---
oExcel.workbooks.CLOSE

* --- Quit Excel ---
oExcel.QUIT
RELEASE oExcel

close all

use matrix88
set filter to recno()=1
delete all
pack
set filter to
close all


thanks again for all the help
 
Try throwing in the following before your SaveAs...

* --- Save Excel Results ---
oExcel.CutCopyMode = .F. && Clear the clipboard
oExcel.DisplayAlerts = .F.

The DisplayAlerts will most likely eliminate the Excel message.

As for the VFP "choose a platform" message, I have not encountered that one in my VFP7 application which does basically the same function.

Good Luck,
JRB-Bldr

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top