Actually i am developing programs which are manipulating on Excel. Until today i was working with only 1 excel file - i mean filling sheet from database and do some calculating, but only on 1 excel file. Today i need to manipulate on 2/3 excel files and i don't know how should i program my template which i am using it looks like that:
How should i implement another excel woorkbook and work with two woorkboks?
Imports Excel = Microsoft.Office.Interop.Excel Module Main 'Create Excel objects Public objApp As New Excel.Application Public objWb As Excel.Workbooks = objApp.Workbooks Public objXlApp As Excel.Application = objWb.Application 'Work directory path Public WorkDirectory = "D:\Files\Reports\" Sub Main() Try With objXlApp 'Open main workbook .Workbooks.Open(Filename:=WorkDirectory & "Data.xls") 'Set Visible/Screen updating .Application.DisplayAlerts = False .Application.Visible = True .Application.ScreenUpdating = True .Sheets("Data").Activate() 'Delete previous data .Cells.Select() .Range("A1").Value = "ID" 'another operations... 'another operations... '..................... End With Catch ex As Exception Call ex Finally 'Realase all excel objects NAR(objWb) NAR(objApp) objXlApp.Quit() NAR(objXlApp) GC.Collect() GC.WaitForPendingFinalizers() End Try End Sub End Module
This post has been edited by nighttrain: 16 August 2012 - 04:57 AM