Some troubles with Excel formatting a cell in python
holger krekel
pyth at devel.trillke.net
Thu May 16 10:58:12 EDT 2002
Andreas Maurer wrote:
> Hi folks,
>
> I tried to "convert" an Excel-macro to python.
> This worked well, 'till I found this VBA-Codeline:
>
> With ActiveCell.Characters(Start:=8, Length:=15).Font
> .Name = "Arial"
> .FontStyle = "Standard"
> etc, etc...
>
> I "translated" this line to python like this:
>
> Excel.ActiveCell.Characters(Start:=8, Length:=15).Font.FontStyle =
> "Standard"
>
> when I start this line in the Interactive Window of pythonwin, I got this
> error-message:
>
> >>> Excel.ActiveCell.Characters(Start:=8, Length:=15).Font.FontStyle =
> "Standard"
> Traceback ( File "<interactive input>", line 1
> Excel.ActiveCell.Characters(Start:=8, Length:=15).Font.FontStyle =
> "Standard"
> ^
> SyntaxError: invalid syntax
>
> I was looking in the msdn and other sources, but I've not found a solution
> yet to avoid
> the trouble with the Characters-methode.
I'd recommend taking the SyntaxError seriously. It points at the
exact character that is wrong. Just remove the ':'. Assignments
in python don't need it.
holger
More information about the Python-list
mailing list