[python-win32] Re: Need help with converting a simple Excel macro
Roger Upole
rwupole at msn.com
Sat Aug 5 05:25:55 CEST 2006
> Hi list,
>
> I have a need to copy 3 rows of data from the top of
> my Excel spreadsheet to another location. I would
> have throught that this should be very straightforward
> since I've done a fair amount of Excel/Python
> programming. Unforturnately, I am stuck on this one.
>
> The VB Macro says I need to:
>
> Range("1:1,2:2,3:3").Select
> Range("A3").Activate
> Selection.Copy
> Rows("20:20").Select
> ActiveSheet.Paste
>
> So, I figure the Python code would be something like:
>
> <xlApp determined already>
> 1) xlSheet=xlApp.ActiveWorkbook.ActiveSheet
> 2) xlSel=xlSheet.Range("1:1,2:2,3:3").Select()
In this line, the result of the Select call is
bound to xlSel, rather than the Range object you need.
Try these 2 lines instead:
xlSel=xlSheet.Range("1:1,2:2,3:3")
xlSel.Select()
Roger
More information about the Python-win32
mailing list