Results 1 to 7 of 7

Thread: set Excel border through VB [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Resolved set Excel border through VB [RESOLVED]

    how to make border cell in excel to be no border via VB?
    i use this syntax
    Code:
      oSheet.Range("A1").BorderAround ColorIndex:=5, Weight:=xlThick
    but can't figure it out how to make it no border

    thx
    Last edited by erickwidya; Dec 15th, 2004 at 09:31 PM.

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Excel through VB

    just record a macro to do what you want, and then edit it to get the code that it uses.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Excel through VB

    thx dave..but i'm not familiar with macro thing..
    can it just go through VB (not VBA) to manipulate it like the one i'm doing now?

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Excel through VB

    the macro code may look a little different, but it will use the same keywords that you can use in your VB program. For instance, the sheet and cell may look a bit different, but the code will still work. Here. I just did it. I recorded a macro called Macro1, highlighted a few cells, clicked stop to end the macro, then opened it for editing. Here is what it looks like.

    Code:
    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 12/15/2004
    '
    
    '
        Range("C5:E7").Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlThick
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThick
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThick
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThick
            .ColorIndex = xlAutomatic
        End With
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    End Sub
    sorry, I had to click three times before I got the thick border, that's why it is longer than necessary. it puts two thin lines, and then the thick one. hmmm, it looks like it only recorded the last one, though.
    Last edited by dglienna; Dec 15th, 2004 at 03:40 AM.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Excel through VB

    thanks Dave for the code
    guess the keyword in this line
    Code:
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone      
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    i'll give it a try..and see what comes up..

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Excel through VB

    i think that you have to give borders to top, bottom, left, and right.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: Excel through VB

    Code:
    oSheet.Range("A1:B1").Borders.LineStyle = xlLineStyleNone
    here is the code looks in VB..
    almost looks like ur code Dave..

    thx for pointing me at right direction

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width