Ejemplo n.º 1
0
NewFile_address = Location_front + Newfile_date + '.xlsx'
OldFile_address = Location_front + Oldfile_date + '.xlsx'

print 'Oldfile date is:		' + Oldfile_date
print 'Newfile date is:		' + Newfile_date
print 'NewFile Month is:	 ' + Newfile_month
print 'OldFile Month is:	 ' + Old_file_month

excel = DispatchEx('Excel.Application')
wbG = excel.Workbooks.Open(OldFile_address)
wbP = excel.Workbooks.Open(Write_file_address)
excel.visible = 0
# note altered sheet name; also .Select is not required

wbG.Worksheets(Old_file_month).Copy(Before=wbP.Worksheets('CombinedData'))
wbP.Worksheets(Old_file_month).Name = 'OLDDATA'

wbX = excel.Workbooks.Open(NewFile_address)
wbX.Worksheets(Newfile_month).Copy(Before=wbP.Worksheets('CombinedData'))
wbP.Worksheets(Newfile_month).Name = 'NEWDATA'
## no running out display alets
excel.DisplayAlerts = 0

excel.RUN('FindNewMPSlines_Macro')
excel.RUN('RemoveCompanion')

wbP.SaveAs(Save_file_address)
excel.Quit()
del excel  # ensure Excel process ends

print 'MPS NewLine has been composed and saved in folder :  ' + Save_file_address