hello all, I am making an application in excel but when I use referecias to other cells or operations between cells mark me an error
Dim excel As New ExcelApplication
Dim book As ExcelWorkbook
excel.Visible = True
book = excel.Workbooks.Add
excel.Range("A1","A1").Select_
excel.ActiveCell.FormulaR1C1=10
excel.ActiveCell.Offset(1,0).Select_
excel.ActiveCell.FormulaR1C1=10
excel.ActiveCell.Offset(1,0).Select_
excel.ActiveCell.FormulaR1C1="=sum(A1:A2)"
excel.ActiveCell.Offset(1,0).Select_
excel.ActiveCell.FormulaR1C1"=R[-3]C+R[-2]C" ' here is the problem send OLEException
excel.ActiveCell.FormulaR1C1= "=R[1]C[-1]" ' this line too have error send OLEException
What does the OLEException message tell you? If you’re running this code in the debugger and you’ve hit this exception, just resume the app and you should see an Exception dialog with some kind of message.
Thanks for your reply. Please check to see if the second last line of code has been changed:
excel.ActiveCell.FormulaR1C1"=R[-3]C+R[-2]C" ' here is the problem send OLEException
Should be:
excel.ActiveCell.FormulaR1C1 = "=R[-3]C+R[-2]C" 'It works now
An equal sign (=) should be added before the quotation marks ("). (Cambie el cdigo con el error de la lnea para incluir un signo igual. Un signo igual no se encuentra.)
Dim excel As New ExcelApplication
Dim book As ExcelWorkbook
excel.Visible = True
book = excel.Workbooks.Add
excel.Range("A1","A1").Select_
excel.ActiveCell.FormulaR1C1=10
excel.ActiveCell.Offset(1,0).Select_
excel.ActiveCell.FormulaR1C1=10
excel.ActiveCell.Offset(1,0).Select_
excel.ActiveCell.FormulaR1C1="=sum(A1:A2)"
excel.ActiveCell.Offset(1,0).Select_
excel.ActiveCell.FormulaR1C1 = "=R[-3]C+R[-2]C" 'It works now
excel.ActiveCell.FormulaR1C1 = "=R[1]C[-1]" 'This works too
in rb and xojo and i get a ole exception atach images with error