I have an IronPython script that replaces some text in an Excel
spreadsheet. Works great. I just ported it to Boo (running with
booi) and I get an Excel error the *second* time through a loop that
is doing the modification. Here is the Boo script:
------------------------------------
import System
import System.IO
def test():
excel as duck = Activator.CreateInstance(Type.GetTypeFromProgID
('Excel.Application'))
#First time through this loop, works great
#Second time, Excel pops up a message on the wrange.Replace stating
that it cannot find any data to replace
for i in range(0,2):
fname = "d:\\work\\scripts\\test${i}.xlsx"
if not File.Exists(fname):
File.Copy('template.xlsx', fname)
wbook = excel.Workbooks.Open(fname)
wsheet = wbook.ActiveSheet
wrange = wsheet.UsedRange
wrange.Replace('ENAME', 'joe')
wbook.Save()
excel.Quit()
test()
---------------------------------------
The IronPython script is exactly the same with appropriate minor
modifications.
Any idea why this is occurring? Thanks in advance. (I can post
sample excel files but for testing you can create a simple sheet with
a string 'ENAME' in one of the cells...)