As part of a previous post I reported the inconsistency in saving reports in Excel format.
I am trying to create a fix using OLE, the intention is that once A5 has created the XL report, I would load the file, select all cells (Ctrl-A), AutoFit the columns and Autofit the rows.
Unfortunately I can't seem to get the syntax correct, I have created a macro in Excel to get the basic properties, but I am buggered if I can get it to parse through Alpha5. Below is the closest I have come, basically I get
as it is, and if I try and place a pointer in front of it
then the element is never found. The other problem I have is save the document and bypassing the overwright warning, it requires user interaction at the moment.
I know not many people use OLE, there are a few examples in the help section, but a dedicated sample list would be helpful for Excel and Word specifically.
I am trying to create a fix using OLE, the intention is that once A5 has created the XL report, I would load the file, select all cells (Ctrl-A), AutoFit the columns and Autofit the rows.
Unfortunately I can't seem to get the syntax correct, I have created a macro in Excel to get the basic properties, but I am buggered if I can get it to parse through Alpha5. Below is the closest I have come, basically I get
a missing or invalid keyword
Code:
x=oWorksheet1.cells.Select
I know not many people use OLE, there are a few examples in the help section, but a dedicated sample list would be helpful for Excel and Word specifically.
Code:
dim oExcel as P dim oWorkbook as P dim oWorksheet1 as P dim fn as C fn = "c:\a.xls" oWorkbook = ole.GetObject(fn) oWorkbook.Application.visible = .T. oWorkbook.windows(1).activate() oWorksheet1 = oWorkbook.Worksheets(1) [COLOR="Red"]oWorksheet1.cells.Select oWorksheet1.Cells.EntireColumn.AutoFit oWorksheet1.Cells.EntireRow.AutoFit[/COLOR] [COLOR="red"]oWorkbook.SaveAs(fn)[/COLOR] oWorkbook.Application.visible = .F. oWorkbook.close() delete oWorkbook delete oExcel
Comment