Link to home
Start Free TrialLog in
Avatar of axnst2
axnst2Flag for United States of America

asked on

Changing Excel cell border from code

Hi Experts,

     I create Excel documents from VB 6.0 and I need to know the following:

How do I change the border of a cell from code?

Thanks,
axnst2
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Hi axnst2,

What border formatting do you want?

Regards,

Patrick
Avatar of axnst2

ASKER

The thick line at the bottom of the cell
SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Assuming you have the Excel library referenced, you can get the constants used above by qualifying with the Excel object:

   Excel.XlBordersIndex.xlEdgeTop

If not, here are the declarations:

Public Enum XlBorderWeight
   xlHairline = 1
   xlMedium = -4138
   xlThick = 4
   xlThin = 2
End Enum

Public Enum XlBordersIndex
   xlInsideHorizontal = 12
   xlInsideVertical = 11
   xlDiagonalDown = 5
   xlDiagonalUp = 6
   xlEdgeBottom = 9
   xlEdgeLeft = 7
   xlEdgeRight = 10
   xlEdgeTop = 8
End Enum

Kevin
I need to do more spell checking...

Kevin
Avatar of axnst2

ASKER

All I basically want to do is set the buttom border and that it so that I can underline my sub totals.  Do I still have to go throug all of this?
Nope:

TargetRange.Borders(9).ColorIndex = 1

Kevin
Avatar of axnst2

ASKER

Kevin,

How exactly would this look in code?  Please assume that I know nothing about working with Excel from VB 6.0 (which happens to be the truth)?

Thanks a bunch,
axnst2
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of axnst2

ASKER

How do I create a range?
Avatar of axnst2

ASKER

Never mind...I got it...thanks a bunch Gentlemen!