我想选中一个单元格以后,让这个单元格中的文字靠右对齐。
通过录制宏,VBA代码如下:
Range("C4").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End WithDelphi代码如下:
ExcelApp.Selection.HorizontalAlignment:=xlRight;
但是这里报错:类型不匹配。应该如何处理?
通过录制宏,VBA代码如下:
Range("C4").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End WithDelphi代码如下:
ExcelApp.Selection.HorizontalAlignment:=xlRight;
但是这里报错:类型不匹配。应该如何处理?
Sheet.Cells[i+2,j].VerticalAlignment:=2;横向,列项居中,你改改数字,应该可以达到居右的效果,我估计:Sheet.Cells[i+2,j].HorizontalAlignment:=2
Sheet.Cells[i+2,j].VerticalAlignment:=1;
试试?
我也苦于这个问题呢,谢谢了
直接用数字代替就行了。