Hi there,
I have a background worker which takes one excel file, opens it, copys a range of cells and pastes it into another excel file.
I have been bashing my head against the wall now and cant seem to find a way round it?
please advice:
oWB1 and oSht1 is the source.Code:Dim moApp1 As Object moApp1 = CreateObject("Excel.Application") moApp1.visible = False Dim oWB1 As Object Dim oSht1 As Object Dim PreviousWeek As String 'MMR - 2008-07-09.xls PreviousWeek = fileName.Substring(0, fileName.Length - 14) & dateEnd.Year.ToString & "-" & FormatDate(dateEnd.AddDays(-7)) & "-" & FormatDay(dateEnd.AddDays(-7)) & ".xls" oWB1 = moApp.workbooks.open(PreviousWeek) oSht1 = oWB1.Sheets("Data").Select() oSht1.Range("A8:E44").Select() = True oSht1.Selection.Copy() oSht = oWB.sheets("Data").Select() oSht.Range("A8").Select() oWB.ActiveSheet.Paste() oWB1.Close(False)
oWB and oSht works fine, it is being used earlier.
Cheers





Reply With Quote