[python-win32] excel xla runautomacros
Tim Roberts
timr at probo.com
Wed Apr 25 22:06:27 CEST 2007
Hussain Jiwani wrote:
> Following is a snippet of code that I have been using to figure out if
> an addin in installed.
>
> xlApp = win32com.client.dynamic.Dispatch('Excel.Application')
> xlApp.DisplayAlerts = 0
> xlApp.Interactive = 1
> if xlApp.Application.Addins.Count <= 0:
> print "Terminating: No add_ins are available"
> xlApp.quit
> return 0
>
> # Addin name should be Analysis ToolPak or Analys32
> lnAddins=0
> for ia in range(1, xlApp.Application.Addins.Count):
>
That stops one too soon. Remember that range(1,4) returns [1,2,3]. You
should either use range(xlApp.Application.AddIns.Count) and refer to
AddIns(ia+1), or you should use range(1, xlApp.Application.AddIns.Count+1)
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-win32
mailing list