我在第 15 行收到此錯(cuò)誤,我不知道為什么。有任何想法嗎?似乎屬性定義明確,所以我完全不知所措。任何幫助將非常感激。AttributeError:“NoneType”對(duì)象沒(méi)有屬性“Sheets”import win32com.clientimport openpyxlimport shutilimport os, subprocessdef Inny_Outy(): input = 'C:/Users/tyler/Desktop/Beef web/Queue' output = 'C:/Users/tyler/Desktop/Beef web/Finished' for filename in os.listdir(input): xl=win32com.client.Dispatch('Excel.Application') ini=xl.Workbooks.Open(input + '/' + filename) inb=xl.Workbooks.Open('C:/Users/tyler/Desktop/Beef Web/Export.xlsx') ini.Sheets('Sheet1').Range('A2:K100000').Copy() inb.Sheets('Export').Paste(inb.Sheets('Export').Range('A2')) inb.Close(True) ini.Close(True) CopyIn_run_macros() Out=xl.Workbooks.Open('C:/Users/tyler/Desktop/Beef Web/Finish.xlsx') add = ini.Sheets.Add(Before = None , After = ini.Sheets(ini.Sheets.count)) add.Name = "E1" add.Name = "231" add.Name = "BIMgen" Out.Sheets('E1').Range('A1:T100000').Copy() ini.Sheets('E1').Paste(ini.Sheets('E1').Range('A1')) Out.Sheets('BIMgen').Range('A1:H100000').Copy() ini.Sheets('BIMgen').Paste(ini.Sheets('BIMgen').Range('A1')) Out.Sheets('231').Range('A1:AG100000').Copy() ini.Sheets('231').Paste(ini.Sheets('231').Range('A1')) ini.Close(True) Out.Close(True) shutil.move(input + '/' + filename, output)def CopyIn_run_macros(): #Run macros xl=win32com.client.Dispatch('Excel.Application') BC=xl.Workbooks.Open('C:/Users/tyler/Desktop/Beef Web/Wall Types Live.xlsm') xl.Application.Run('Python2') EXP=xl.Workbooks.Open('C:/Users/tyler/Desktop/Beef Web/Export.xlsx') print("Importing Export To BeefCake....") EXP.Sheets('Export').Range('A2:K100000').Copy() BC.Sheets('Raw Export').Paste(BC.Sheets('Raw Export').Range('A12')) EXP.Close(True) print("Complete.") print("Running Macros....") xl.Application.Run('Python') print("Complete.")Inny_Outy()
1 回答

慕神8447489
TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超1個(gè)贊
inb=xl.Workbooks.Open('C:/Users/tyler/Desktop/Beef Web/Export.xlsx')
我猜這是返回 None 因?yàn)槲募淮嬖?,或者目錄搞砸了?/p>
添加回答
舉報(bào)
0/150
提交
取消