E
eBob.com
I am building an Excel spreadsheet using VB.Net code. I want the vertical
alignment for all cells to be "Top". To know what code I'd need I turned on
macro recording and went through the manual process. I got the following
result ...
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
I only care about the vertical alignment, so I am not trying to do any of
the other stuff in VB.Net. Instead of the Cells.Select I found that in my
code I'd need "objSheet.Cells.Select()" - that compiles and builds without
error. It's the vertical alignment line that is causing me problems.
"objSheet.Selection.VerticalAlighment = objApp.xltop" does not work because
Selection is not a member of Excel._Worksheet and
"objSheet.VerticalAlighment = objApp.xltop" does not work because
verticalalignment is not a member of Excel._Worksheet.
I'll appreciate any help anyone can offer. Thanks, Bob
alignment for all cells to be "Top". To know what code I'd need I turned on
macro recording and went through the manual process. I got the following
result ...
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
I only care about the vertical alignment, so I am not trying to do any of
the other stuff in VB.Net. Instead of the Cells.Select I found that in my
code I'd need "objSheet.Cells.Select()" - that compiles and builds without
error. It's the vertical alignment line that is causing me problems.
"objSheet.Selection.VerticalAlighment = objApp.xltop" does not work because
Selection is not a member of Excel._Worksheet and
"objSheet.VerticalAlighment = objApp.xltop" does not work because
verticalalignment is not a member of Excel._Worksheet.
I'll appreciate any help anyone can offer. Thanks, Bob