Change excel background colors, Sheet name, alignment etc.

  • Thread starter Thread starter Elad Frid
  • Start date Start date
E

Elad Frid

Hi

I'm trying to export a datagrid created in asp.net to excel using
VBScript
It's working great but how can I change the background colors, Sheet
name, alignment in the excel ?
Where can I find documentation about it ?

That the code I'm using
<script language= "vbscript">
Sub Button2_onclick()
Dim sHTML
sHTML = window.Form1.children("DataGrid1").outerhtml
Dim oXL, oBook
Set oXL = CreateObject("Excel.Application")
Set oBook = oXL.Workbooks.Add

oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oXL.Visible = true
oXL.UserControl = true
end sub
</script>

Thanks

Elad.
 
A sheet doesn't have a background color. You have to change the interior
color of cells (range objects)

oBook.HTMLProject.HTMLProjectItems("Sheet1").Name = "NewName"

each cell has a horizontalalignment and verticalAlignment property. This is
accessed through the range object hierarchy.
 
;-)))
Tom Ogilvy said:
A sheet doesn't have a background color.

I'm so confused....

Sub Macro1()
' Macro enregistrée par Modeste Gee-Dee
With ActiveWorkbook.Styles("Normal").Interior
.ColorIndex = 40
.PatternColorIndex = 3
.Pattern = xlLightDown
End With
Selection.Style = "Normal"
End Sub
;-)))
@+
 
I don't understand the confusion. You have changed the interior color of
the cells.

With Cells
.Interior.ColorIndex = 40
.PatternColorIndex = 3
.Pattern = xlLightDown
End with

Would actually appear to change the entire sheet while your sample provides
no such guarantee.

I missed where you demonstrated that there is a background color property or
related for the worksheet object??? So perhaps you are confused.
 
;-)))
Oh Tom,
I'm really confused, it was a joke :
there is à background but with no color,

I wanted simply to point out that the default background color of the cells
is defined by the "Normal" style.

Would you excuse me for my attempt,
I learned so much by silently reading you for a few years.

Regards
 
Back
Top