Hi guys. I made a post the other day with reference to disposing COM objects that were created by using Excel so that I could properly dispose of the Excel.exe.
Following the 2 dot rule, after I have downloaded data using my datatable etc I then initialize an instance of Excel below and rename the sheet. This is just something I have done as an example.
My previous experience is with using the built in VBA inside the Excel application. I had this VBA code which I used in Excel to input formula into Column 33 all the way down.
Now that I have moved on to Visual studio I would like some help/advice on how to do the same using the 2 dot rule correctly or if I can ignore the 2 dot rule in parts.
Some code examples would be great on the best way to declare my variables when doing this as I don't even know how to start off
Kind Regards
Following the 2 dot rule, after I have downloaded data using my datatable etc I then initialize an instance of Excel below and rename the sheet. This is just something I have done as an example.
Code:
Dim xlApp As excel.Application = Nothing
Dim xlWorkBooks As excel.Workbooks = Nothing
Dim xlWorkBook As excel.Workbook = Nothing
Dim xlWorkSheets As excel.Sheets
Dim xlWorkSheet As excel.Worksheet = Nothing
Dim xlCells As excel.Range = Nothing
xlApp = New excel.Application
xlWorkBooks = xlApp.Workbooks
''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''
xlWorkBook = xlWorkBooks.Open("" & Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\" & MatchID & ".xlsx")
xlWorkSheets = xlWorkBook.Sheets
xlWorkSheet = xlWorkSheets("sheet1")
xlWorkSheet.Name = MatchID
xlApp.Visible = True
Code:
Range("a2", Cells(Rows.Count, "a").End(xlUp)).Offset(, 32) = "=IF(AND(RC[-29]=""1"",RC[-24]<>0,RC[-23]<>""02""),1,IF(AND(RC[-29]=""1"",RC[-24]=0,RC[-23]=""02"",RC[-20]<>0),1,""FALSE""))"
Some code examples would be great on the best way to declare my variables when doing this as I don't even know how to start off
Kind Regards