excel application

L

luca72

Hello here is the code:

from win32com.client import Dispatch
packing = Dispatch("Excel.Application")
packing.Visible = 1
packing.Workbooks.Add()
#packing.Worksheets.Add()
packing.ActiveSheet.Range("A1").ColumnWidth = 8
packing.ActiveSheet.Range("B1").ColumnWidth = 12
packing.ActiveSheet.Range("C1").ColumnWidth = 6
packing.ActiveSheet.Range("D1").ColumnWidth = 6
packing.ActiveSheet.Range("E1").ColumnWidth = 6
packing.ActiveSheet.Range("F1").ColumnWidth = 60
packing.ActiveSheet.Range("G1").ColumnWidth = 13
packing.ActiveSheet.Range("H1").ColumnWidth = 10
packing.ActiveSheet.Range("A8:H9").Select()
packing.ActiveSheet.Selection.Borders(xlDiagonalDown).LineStyle
= xlNone

The error messege is

global name xlNone is not definied

what I have mistaken?

Regards

Luca
 
L

lucmult

Hi Luca,

The words xlDiagonalDown e xlNone are Excel constants and don't are in
the Local NameSpace

use these values:
xlNone = -4142
xlDiagonalDown = 5

Then the last line stay like that
"""
packing.ActiveSheet.Selection.Borders(5).LineStyle = -4142
# Excel Constants: xlNone = -4142 xlDiagonalDown = 5
"""

When use the integer values in your code remeber to comment the
significant of these values, to a future corrections :)

[],

Luciano Pacheco
 
P

Petr Jakes

Luca,
you can find a lot of answers to your questions on this discussion
group. If you will try to search using key words "excel constants" for
example, you will get the link to the following link (among others):
http://tinyurl.com/go3qf

IMHO it is good idea to search the web and discussion groups before
posting questions (I am not saying it is a bad idea to ask here, I am
only trying to show an simple alternative how to get an answers to your
questions to you)

HTH
Regards
Petr Jakes
 

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,453
Members
48,137
Latest member
IndiraMcCo

Latest Threads

Top