Good Morning,
I have a rather odd thing happening with an Excel WorkSheet that I am creating through .Net.
I load up an existing workbook
Dim _xlApp As New Excel.Application
Dim _xlWorkbook As Excel.WokBook = _xlApp.Workbooks.Open(_templateFileName)
set it to be visible before populating it (for debugging purposes)
_xlApp.Visible = True
I then go on to populate the existing template.
Private Sub GenerateOceanFreightGrid()
Dim columnCount As Integer = 4 ' _standardColumnCount
Dim columnInsertPosition As Integer = 5
If MyBooleanValue() Then
_xlSheet.Columns(4).Insert()
_xlSheet.Cells(7, 4) = "My Header Value"
columnInsertPosition += 1
columnCount += 1
End If
When i set a breakpoint on the "Private Sub Gen.." line, and step through the code line by line, it inserts a new column for each variable declared, so in this case it will insert two columns before it even hits the "If MyBooleanValue()..." line (I can watch it actually happen due to the Excel app being visible). However, if i dont set a breakpoint and just let the code run straight through this doesnt happen.
There is no multi threading happening or anything else that i suspect would have any impact on the code.
My obvious work around is to not set the breakpoint, i was just wondering if anyone has seen this happen before and for what reason?
Thanks