Excel-win32com的宏操作
import win32com.client xl =win32com.client.Dispatch("Excel.Application") #实例化Excel应用程序 wb =xl.Workbooks.Open(r'C:\Users\Desktop\test1.xlsm') xl.Application.Run('test1.xlsm!模块1.getTime2("现在时刻")') wb.Save() xl.Application.Quit()
宏指令:
Sub getTime() Sheet1.Cells(1, 1) = Now End Sub Sub getTime2(title As String) Sheet1.Cells(2, 1) = title & " : " & Now End Sub Function getTime3(title As String) As String getTime3 = title & " : " & Now End Function
,Best Wish 不负年华