Passing parameters to VB

K

koia

Hi,

I am using win32com for the Python interface to my Excel shreadsheets.

When I turn on Macro recordiong in Excel while filling a rectangle with
text information, a part of the VB code produced is the following:

With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic

What is the syntax for passing the parameters Start:=1, Length:=11 to
VB from a Python function, if I want to control these properties of the
text in the Excel spreadsheet?

Thanks in advance!

/ koia
 
T

Tim Roberts

koia said:
Hi,

I am using win32com for the Python interface to my Excel shreadsheets.

When I turn on Macro recordiong in Excel while filling a rectangle with
text information, a part of the VB code produced is the following:

With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic

What is the syntax for passing the parameters Start:=1, Length:=11 to
VB from a Python function, if I want to control these properties of the
text in the Excel spreadsheet?

If you check the object model documentation, you'll find that "Start" and
"Length" are the only two parameters to Characters, so Characters(1,11)
should work.

However, in a few minutes of experimentation, I was unable to get
Characters to accept any parameters from Python. I can set the whole cell
to bold by this:

xl = win32com.client.Dispatch("Excel.Application")
wb = xl.ActiveWorkbook
ws = wb.Worksheets(1)
r = ws.Range("A1")
r.Characters.Font.Bold = True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,291
Messages
2,571,455
Members
48,131
Latest member
AntoniaSep

Latest Threads

Top