formatting excel cell + vertical alignment

D

dave

Hello
I'm trying to write data in excel sheet and formatting cells
Below is the code snippet:

Set objXL = CreateObject("Excel.Sheet")
objXL.Application.Visible = True

objXL.Application.Columns("A:G").EntireColumn.AutoFit
objXL.Application.Columns("A:G").EntireColumn.Font.Name = "Verdana"
objXL.Application.Columns("A:G").EntireColumn.Font.Size = "8"

objXL.Application.Columns("A:G").VerticalAlignment = xlTop 'gives
errors

objXL.Application.Range("A6:G6").Font.Bold = True
objXL.Application.Range("A6:G6").Font.Italic = True
objXL.Application.Range("A6:G6").Font.Name = "Times New Roman"
objXL.Application.Range("A6:G6").Font.Size = 11
objXL.Application.Range("A6:G6").Font.Color = RGB(0, 0, 128)


But I'm able to set verticalalignment property of the cell..Rest of the code
works fine...
Any ideas
Thanx
 
A

Alex Dybenko

dave,
best practice - it to start macro recording in excel, make formatting you
need, stop recording and then check what code excel produced.
Also check, if you have a late binding - make sure you define all constants
like xlTop in access module
 
D

dave

Thanx for the reply..It's good practise to use macro and I did.
It produce code something like this

Columns("A:A").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

but still couldn't figure out how to define constant xlTop and what value I
need to set?
Thanx again...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top