a „oeáã@sæddlZddlZddlmZddlmZmZmZmZddl m Z ej dddddd �ej d dd ddd �e  d dddd g¡Gdd„dƒZ Gdd„dƒZdd„Zdd„ZedkrâddlZejj e¡dejvrÚeeƒneeƒdS)éN)Ú universal)ÚDispatchÚDispatchWithEventsÚ constantsÚgencache)Ú COMExceptionz&{00020813-0000-0000-C000-000000000046}ééT)Z bForDemandz&{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}éz&{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}Ú_IDTExtensibility2c@seZdZdd„ZdS)Ú ButtonEventcCs$ddl}ddl}| dd|j¡|S)NrzHello from Pythonz Python Test)Úwin32conÚwin32uiZ MessageBoxZ MB_OKCANCEL)ÚselfZbuttonÚcancelr r©rú:C:\Program Files\Certbot\pkgs\win32com\demos\excelAddin.pyÚOnClickGszButtonEvent.OnClickN)Ú__name__Ú __module__Ú __qualname__rrrrrr Fsr c@sXeZdZdgZgZejZdZdZ dZ dd„Z dd„Z d d „Z d d „Zd d„Zdd„ZdS)Ú ExcelAddinr z&{C5482ECA-F559-45A0-B078-B2036E6F011A}zPython.Test.ExcelAddinz)win32com.server.policy.EventHandlerPolicycCs d|_dS)N)Ú appHostApp)rrrrÚ__init__WszExcelAddin.__init__c Cstd||||ƒzl||_|jjjdtjtjdd�}|jjtjdd�}t |t ƒ}|_ tj |_ d|_d|_d|_d |_d|_WnŒtj�y}zp|j\}} } } td || fƒ| durÀtd ƒn4| \} } }}}}td | ƒtd |ƒtd||fƒWYd}~n d}~00dS)NÚ OnConnectionÚ PythonBarT)ÚNameZPositionZMenuBarZ TemporaryZ Greetings)ÚTypeZ Parameterz&PythonzPython rules the WorldZ34z&The Excel call failed with code %d: %sz&There is no extended error informationzThe source of the error iszThe error message isz$More info can be found in %s (id=%d))ÚprintrÚ CommandBarsZAddrZ msoBarTopZmsoBarTypeNormalZControlsZmsoControlButtonrr Z toolbarButtonZmsoButtonCaptionZStyleZ BeginGroupZCaptionZ TooltipTextZWidthZVisibleÚ pythoncomZ com_errorÚargs)rZ applicationZ connectModeZaddinÚcustomZcbcMyBarZ btnMyButtonZxxx_todo_changemeÚhrÚmsgÚexcÚargZwcodeÚsourceÚtextZhelpFileZhelpIdZscoderrrrZs<üÿÿ     zExcelAddin.OnConnectioncCs tdƒ|j d¡jd|_dS)NÚOnDisconnectionr)rrrZDelete)rÚmoder"rrrr){szExcelAddin.OnDisconnectioncCstd|ƒdS)NÚOnAddInsUpdate©r©rr"rrrr+€szExcelAddin.OnAddInsUpdatecCstd|ƒdS)NÚOnStartupCompleter,r-rrrr.ƒszExcelAddin.OnStartupCompletecCstd|ƒdS)NÚOnBeginShutdownr,r-rrrr/†szExcelAddin.OnBeginShutdownN)rrrZ_com_interfaces_Z_public_methods_r ZCLSCTX_INPROC_SERVERZ _reg_clsctx_Z _reg_clsid_Ú _reg_progid_Z_reg_policy_spec_rrr)r+r.r/rrrrrOs!rcCsxddl}| |jd¡}| ||j¡}| |dd|jd¡| |dd|jd¡| |dd|jd¡| |dd|jd ¡dS) Nrz&Software\Microsoft\Office\Excel\AddinsZCommandLineSafeZ LoadBehaviorr Z Descriptionz Excel AddinZ FriendlyNamezA Simple Excel Addin)ÚwinregÚ CreateKeyÚHKEY_CURRENT_USERr0Ú SetValueExÚ REG_DWORDÚREG_SZ)Úklassr1ÚkeyZsubkeyrrrÚ RegisterAddinŠsÿr9cCs8ddl}z| |jd|j¡Wnty2Yn0dS)Nrz'Software\Microsoft\Office\Excel\Addins\)r1Ú DeleteKeyr3r0Ú WindowsError)r7r1rrrÚUnregisterAddin—sþ r<Ú__main__z --unregister)Úsysr Zwin32comrZwin32com.clientrrrrZwin32com.server.exceptionrZ EnsureModuleZRegisterInterfacesr rr9r<rZwin32com.server.registerZserverÚregisterZUseCommandLineÚargvrrrrÚ1s.   ÿ ÿ ÿ ;