excel application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • luca72

    #1

    excel application

    Hello here is the code:

    from win32com.client import Dispatch
    packing = Dispatch("Excel .Application")
    packing.Visible = 1
    packing.Workboo ks.Add()
    #packing.Worksh eets.Add()
    packing.ActiveS heet.Range("A1" ).ColumnWidth = 8
    packing.ActiveS heet.Range("B1" ).ColumnWidth = 12
    packing.ActiveS heet.Range("C1" ).ColumnWidth = 6
    packing.ActiveS heet.Range("D1" ).ColumnWidth = 6
    packing.ActiveS heet.Range("E1" ).ColumnWidth = 6
    packing.ActiveS heet.Range("F1" ).ColumnWidth = 60
    packing.ActiveS heet.Range("G1" ).ColumnWidth = 13
    packing.ActiveS heet.Range("H1" ).ColumnWidth = 10
    packing.ActiveS heet.Range("A8: H9").Select()
    packing.ActiveS heet.Selection. Borders(xlDiago nalDown).LineSt yle
    = xlNone

    The error messege is

    global name xlNone is not definied

    what I have mistaken?

    Regards

    Luca

  • lucmult@gmail.com

    #2
    Re: excel application

    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.ActiveS heet.Selection. Borders(5).Line Style = -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

    Comment

    • luca72

      #3
      Re: excel application

      Thanks a lot Luciano

      Regards Luca

      Comment

      • Petr Jakes

        #4
        Re: excel application

        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

        Comment

        • luca72

          #5
          Re: excel application

          Thanks Peter

          Regards

          Luca

          Comment

          Working...