M
mrid via DotNetMonster.com
hi. im exporting data from a vb form to excel. i am able to create a new
excel file, save and edit it without any trouble, but the formatting is
giving me hell! i need to be able to show certain cells in bold, with
underlining etc. i dont understand how, but in the following code, the
instruction for bold gets picked up for all the cells (even when i specify
font.bold = false), and the underlining is haphazardly used. the font colour
formatting is also not getting picked up...
can someone please tell me how this thing works and what i should do?
With xlsheet
.Range("B1", "I50").RowHeight = 15
.Range("a1", "i50").ColumnWidth = 8.43
'title of sheet
.Cells(1, 1).Font.ColorIndex = 32
.Cells(1, 1).Style.font.size = 14
.Cells(1, 1).Font.Name = "Arial Black"
.Cells(1, 1).Value = "CONSUL"
'ISO form code
.Cells(2, 7).Font.ColorIndex = 1
.Cells(2, 7).Style.font.size = 10
MsgBox("ISO CODE")
.Cells(2, 7).Style.font.bold = True
.Cells(2, 7).style.font.underline = False
.Cells(2, 7).Font.Name = "Batang"
.Cells(2, 7).Value = "CRF - 02"
'branch
.Cells(2, 1).Style.font.name = "batang"
.Cells(2, 1).style.font.underline = False
MsgBox("branch underline")
.Cells(2, 1).style.font.bold = True
MsgBox("branch bold")
.Cells(2, 1).Style.font.size = 11
.Cells(2, 1).Value = ds.Tables("form1").Rows(ctr).Item("branch")
' form title
.Cells(3, 3).Style.font.underline = True
.Cells(3, 3).Style.font.size = 11
.Cells(3, 3).Value = "CONTRACT REVIEW CUM BDI FORM"
'se code
.Cells(6, 7).Style.font.size = 9
.Cells(6, 7).Style.font.bold = True
.Cells(6, 7).Value = "SE Code"
.Cells(6, 8).Style.font.size = 11
.Cells(6, 8).Value = ds.Tables("form1").Rows(ctr).Item("sec")
'equipment type
.Cells(6, 2).Style.font.size = 11
.Cells(6, 2).Font.ColorIndex = 15
.Cells(6, 2).Font.Name = "Arial black"
.Cells(6, 2).Value = equip
.Cells(6, 1).Value = "Equip"
excel file, save and edit it without any trouble, but the formatting is
giving me hell! i need to be able to show certain cells in bold, with
underlining etc. i dont understand how, but in the following code, the
instruction for bold gets picked up for all the cells (even when i specify
font.bold = false), and the underlining is haphazardly used. the font colour
formatting is also not getting picked up...
can someone please tell me how this thing works and what i should do?
With xlsheet
.Range("B1", "I50").RowHeight = 15
.Range("a1", "i50").ColumnWidth = 8.43
'title of sheet
.Cells(1, 1).Font.ColorIndex = 32
.Cells(1, 1).Style.font.size = 14
.Cells(1, 1).Font.Name = "Arial Black"
.Cells(1, 1).Value = "CONSUL"
'ISO form code
.Cells(2, 7).Font.ColorIndex = 1
.Cells(2, 7).Style.font.size = 10
MsgBox("ISO CODE")
.Cells(2, 7).Style.font.bold = True
.Cells(2, 7).style.font.underline = False
.Cells(2, 7).Font.Name = "Batang"
.Cells(2, 7).Value = "CRF - 02"
'branch
.Cells(2, 1).Style.font.name = "batang"
.Cells(2, 1).style.font.underline = False
MsgBox("branch underline")
.Cells(2, 1).style.font.bold = True
MsgBox("branch bold")
.Cells(2, 1).Style.font.size = 11
.Cells(2, 1).Value = ds.Tables("form1").Rows(ctr).Item("branch")
' form title
.Cells(3, 3).Style.font.underline = True
.Cells(3, 3).Style.font.size = 11
.Cells(3, 3).Value = "CONTRACT REVIEW CUM BDI FORM"
'se code
.Cells(6, 7).Style.font.size = 9
.Cells(6, 7).Style.font.bold = True
.Cells(6, 7).Value = "SE Code"
.Cells(6, 8).Style.font.size = 11
.Cells(6, 8).Value = ds.Tables("form1").Rows(ctr).Item("sec")
'equipment type
.Cells(6, 2).Style.font.size = 11
.Cells(6, 2).Font.ColorIndex = 15
.Cells(6, 2).Font.Name = "Arial black"
.Cells(6, 2).Value = equip
.Cells(6, 1).Value = "Equip"