Hello,
I have been struggling with underlining Cell in Excel sheet. I have ASP page. Which picks up Excel template and fill value in it, and at last saving it as some other name.
I need to put bottomborder(xlEdgeBottom)
to certain Cell or Range. I tried so many thing, but not working. Help me please.
Set ExcelApp = CreateObject("Excel.Applic
ation")
ExcelApp.Application.Visib
le = True
'Close all pending books
ExcelApp.Workbooks.Close
'Open the template
Set ExcelBook = ExcelApp.Workbooks.Open("\
\DB_Server
\DB\MainMe
nu\Reports
\etmp\rpt_
quote_shee
t.xls", , True)
lsFullFileName = "\\DB_Server\DB\MainMenu\R
eports\etm
p\rpt_quot
e_sheet_te
mp.xls"
Set oFS = CreateObject("Scripting.Fi
leSystemOb
ject")
if (oFs.FileExists(lsFullFile
Name) = TRUE) then
oFS.DeleteFile(lsFullFileN
ame)
End if
**************************
****
Opening record sets.
Assigning value in Cells
Etc..
**************************
****
ExcelBook.Sheets(1).Protec
t DrawingObjects=False, Contents=False, Scenarios=False, Password="secret"
ExcelBook.SaveAs lsFullFileName
ExcelApp.WorkBooks.Close
ExcelApp.Application.Quit
Set ExcelApp = Nothing
I tried all following combinations not worked.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaxl10/html/xlobjBorder.asphttp://www.vbforums.com/archive/index.php/t-42131.html http://knowledgemanagement.ittoolbox.com/groups/groups.asp?v=brio-l&i=664368 'ExcelBook.Worksheets(1).R
ange("A5:G
5").Border
s(xlEdgeBo
ttom).Colo
r = RGB(255, 0, 0)
'ExcelBook.Worksheets(1).C
ells(ctr, 10).Borders(xlEdgeBottom).
Color = RGB(255, 0, 0)
'ExcelBook.Worksheets(1).R
ange("J" & ctr).Borders(xlEdgeBottom)
.Color = RGB(255, 0, 0)
'ExcelBook.Worksheets(1).R
ange("J" & ctr).Borders(xlEdgeBottom)
.LineStyle
= xlContinuous
'ExcelBook.Worksheets(1).C
ells(ctr, 10).Borders(xlEdgeBottom).
LineStyle = xlContinuous
'ExcelBook.Worksheets(1).R
ange("J" & ctr).Borders(xlEdgeBottom)
.Weight = xlThin
'ExcelBook.Worksheets(1).R
ange(Cells
(ctr, 10),Cells(ctr, 17)).Borders(xlEdgeBottom)
.LineStyle
= xlContinuous
'ExcelBook.Worksheets(1).R
ange(Cells
(ctr, 10),Cells(ctr, 17)).Borders.LineStyle = xlThick
'ExcelBook.Worksheets(1).R
ange("A1")
.Borders.L
ineStyle = xlDouble
'ExcelBook.Worksheets(1).R
ange("A1")
.Borders.L
ineStyle = xlThick
'ExcelBook.Workbooks.Item(
1).Sheets.
Item(1).Ra
nge("J" & ctr).Borders.Item(xlEdgeBo
ttom).Line
Style = xlContinuous
'ExcelBook.Workbooks.Item(
1).Sheets.
Item(1).Ra
nge("J" & ctr).Borders.Item(xlEdgeBo
ttom).Weig
ht = xlThin
'ExcelBook.WorkSheets(1).R
ange("J" & ctr).Borders.Item(xlEdgeBo
ttom).Line
Style = xlContinuous
'ExcelBook.WorkSheets(1).R
ange("J" & ctr).Borders.Item(xlEdgeBo
ttom).Weig
ht = xlThin, xlHairline
'ExcelBook.Worksheets(1).R
ange("A1")
.CurrentRe
gion.Borde
rs.LineSty
le = xlThick
'ExcelBook.Worksheets(1).R
ange("A1")
.CurrentRe
gion.Borde
rs(xlEdgeB
ottom).Lin
eStyle = xlContinuous
'ExcelBook.Worksheets(1).R
ange("G8")
.Borders(x
lEdgeBotto
m).LineSty
le = xlContinuous
'ExcelBook.Worksheets(1).R
ange("G8")
.Borders(x
lEdgeBotto
m).Weight = xlThin
'ExcelBook.Worksheets(1).R
ange("G8")
.Borders(x
lEdgeBotto
m).ColorIn
dex = xlAutomatic
I tried following combinations, it worked, but I dont want to make all surrounding border, I just want the bottom border(you can say underline of cell/range, not font).
'''''''''ExcelBook.Workshe
ets(1).Ran
ge("G8").B
orders.Lin
eStyle = xlContinuous
'''''''''ExcelBook.Workshe
ets(1).Ran
ge("G8").B
orders.Col
orIndex = xlAutomatic
Thanks,
Start Free Trial