XS0144 Error on Excel
Posted: Sat Dec 14, 2024 8:28 am
Hi All,
when USING Microsoft.Office.Interop.Excel.Application at beginning of .prg I get the following error:
XS0144: Cannot create an instance of the abstract type or interface 'Microsoft.Office.Interop.Excel.GroupBox'
I think the reason is that a VO.Groupbox is already defined so I removed the USING directive and changed my code like that:
but now I'm facing another error
XS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
on this line:
How to solve this?
thanks
Stefano
P.S. I'm getting another error on this line of code
Error XS0266 Cannot implicitly convert type 'int' to 'Microsoft.Office.Interop.Excel.XlPageOrientation'. An explicit conversion exists (are you missing a cast?)
when USING Microsoft.Office.Interop.Excel.Application at beginning of .prg I get the following error:
XS0144: Cannot create an instance of the abstract type or interface 'Microsoft.Office.Interop.Excel.GroupBox'
I think the reason is that a VO.Groupbox is already defined so I removed the USING directive and changed my code like that:
Code: Select all
LOCAL oExcel AS Microsoft.Office.Interop.Excel.Application
LOCAL oWorkSheet AS Microsoft.Office.Interop.Excel.Worksheet
LOCAL oRange AS Microsoft.Office.Interop.Excel.Range
LOCAL oFont AS Microsoft.Office.Interop.Excel.Font
LOCAL oWorkBooks AS Microsoft.Office.Interop.Excel.Workbooks
//... some other code
oExcel := Microsoft.Office.Interop.Excel.Application{}
oExcel:Visible := TRUE
oExcel:ScreenUpdating := FALSE
oWorkBooks := oExcel:Workbooks
oWorkBooks:OpenText(cFile, uOrigin, uStartRow, uDataType, uTextQualifier, uConsecutiveDelimiter, uTab, uSemicolon, uComma,uSpace, uOther, uOtherChar, uFieldInfo)
oWorkSheet := oExcel:ActiveSheet
oRange := oWorkSheet:Range[cCol,cRow]
oRange:SELECT()
oFont := oRange:Font
oFont:Name := "Courier New"
oFont:Size := 10
oFont:Strikethrough := FALSE
oFont:Superscript := FALSE
oFont:Subscript := FALSE
oFont:OutlineFont := FALSE
oFont:Shadow := FALSE
oRange:Columns:AutoFit // Adatta automaticamente le colonne
oRange := oWorkSheet:Range[ "A1","A1"]
oRange:SELECT()
XS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
on this line:
Code: Select all
oRange:Columns:AutoFit // Adatta automaticamente le colonne
thanks
Stefano
P.S. I'm getting another error on this line of code
Code: Select all
oWorkSheet:PageSetup:Orientation := 2 // xlLandascape