modifiying Excel Cells from VB

  • Thread starter Thread starter Mike Fellows
  • Start date Start date
M

Mike Fellows

i have some code that pulls a large amount of data from a database
and puts it into an excel spreadsheet, some excel formulas are inserted
and the whole lot gets printed out (excel in invisble during all this), and
excel is closed

i currently setup my excel spreadsheet like this:

Dim excel_app As Object
excel_app = CreateObject("Excel.Application")
Dim row As Integer
excel_app.Visible = False
excel_app.Workbooks.Add()
With excel_app
.Columns("A:A").ColumnWidth = 20
.Range("A1").Select()
.ActiveCell.FormulaR1C1 = "Detailed Closed Report"
With .Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 18
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.ColorIndex = 0
End With
End With

As you can see, I give the column a title and set the propeties of the
column

Now what i want to do is setup wraptext on my column, ive tried .WrapText
but this
does not work.

also i need to set the alignment of the cells to vertical, again i am unable
to find the
commands that do this.

Any help with this is as usual greatly appreciated

Regards

Mike Fellows
 
Hi
To align the cells vertically use :

objSheet.Range("e3").Orientation = 90

Kind Regards
Jorge
 
sorry you misunderstood me

i need to align horizontal text to the top of the cell

i.e. if the cell is double height, as standard the text is aligned to the
bottom
i need to align this text to the top

Thanks

Mike
 
Mike Fellows said:
i want to do is setup wraptext on my column, ive tried .WrapText
but this
does not work.

also i need to set the alignment of the cells to vertical

Try

.WrapText = True
.VerticalAlignment = xlTop

--
 
Back
Top