Hello,
Till last Friday, the following code was working great. No crashes, excellent performance.
dim excel As new ExcelApplication
dim book As ExcelWorkbook
dim sheet As ExcelWorksheet
'=======Add New Workbook=========
book=excel.workbooks.add
'======Risk Input Worksheet=============
excel.worksheets(1).name="Input"
excel.worksheets(1).Range ("A1").value="ID" 'Risk ID number, numeric
excel.worksheets(1).Range("A1").Select_
excel.worksheets(1).Range("A1").Addcomment
excel.worksheets(1).Range("A1").Comment.Text ("pippo")
excel.worksheets(1).Range("A1").Comment.Visible = False
excel.worksheets(1).Range("A2").Select_
excel.worksheets(1).Range("A2").Addcomment
excel.worksheets(1).Range("A2").Comment.Text ("Alberto")
excel.worksheets(1).Range("A2").Comment.Visible = False
excel.visible = true // Show the excel application
excel = Nil //Set the object to Nil
Exception err as OLEException // Check for an error
MsgBox err.message // Display the error
Now, the only way I am able to see the "ID", "Comments", etc, after Excel opens is by moving the "excel.visible=True" up after "book=excel.workbooks.add". (Why?)
If I run the code as shown, Excel opens but that is all. No text in cell or comments.
If I move the "visible..." property up, it works.
For a few months I have been working in an application where the "visible" property was always placed as shown and had no problem at all. I based all my code after reading the excellent book from Mr. Eugene Dakin "Program Excel 2010 with REALStudio in Windows".
I did updated RB to the current revision 2012r2.1 last March, but it was working great since then till last week and no other changes or upgrades took place in my machine.
Is this a bug? Have anyone experienced this before? Why I need to change the location of a line of code to make it work, while it was working for many months when placed at the end of the code as shown? Am I missing anything?
The reason I placed the "visible.." property at the end is to gain efficiency by only presenting the open worksheet after it was all configured at once.
Thank you in advance for any input.
Luis.