horizo​​ntalAlignment不适用于xlFill

horizo​​ntalAlignment不适用于xlFill

本文介绍了horizo​​ntalAlignment不适用于xlFill的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使excel中的列适合我提供的列大小,我正在尝试使用horizo​​ntalAlignment属性来执行此操作.

I am trying to make my column in excel fit into the column size that I give it, I am trying to use the property horizontalAlignment to do this.

我可以在xlCenter上使用它,但是我需要做xlFill,但是xlFill没有值.

I can get it working with xlCenter, but I need to do xlFill but there isn't a value for xlFill.

With objExcelAssist.worksheet.columns("N:N")
    .horizontalAlignment = xlCenter
End With

我尝试过的事情:

With objExcelAssist.worksheet.columns("N:N")
    .horizontalAlignment = xlFill
End With

With objExcelAssist.worksheet.columns("N:N")
    .horizontalAlignment = xlFillDefault
End With

到目前为止还没有成功,我用错了名字吗?

Not had any success so far, am I use the wrong name to fill?

--------------编辑------------------

-------------- EDIT ------------------

shrinkToFit所做的所有事情都是使我的文字变小

All shrinkToFit did was make my text smaller

我只需要它,这样它就不会在不影响文本大小的情况下与下一行重叠

I need it just so it doesn't overlap the next row without effecting the text size

推荐答案

这是您要尝试的吗?

With objExcelAssist.Worksheet.Columns("N:N")
    .HorizontalAlignment = xlFill
    .ShrinkToFit = True
End With

仅供参考:您可以使用的其他东西是

FYI: The other things that you have at your disposal are

    .HorizontalAlignment
    .VerticalAlignment
    .WrapText
    .Orientation
    .AddIndent
    .IndentLevel
    .ShrinkToFit
    .ReadingOrder
    .MergeCells

编辑

评论的关注

最后我能确定的问题是您正在与MS-Excel后期绑定,因此MS-Access无法识别这些常量.在这种情况下,您有2个选择

The problem finally what I could ascertain is that you are latebinding with MS- Excel and hence MS - Access didn't recognize those constants. You have 2 options in such a case

A.在代码顶部声明常量.例如

A. Declare the constants at the top of the code. For example

Const xlFill As Integer = 5
'~~> Other COnstants You can check their values in Excel Object Browser
Const xlBottom As Integer = -4107
Const xlContext As Integer = -5002
Const xlCenter As Integer = -4108

,依此类推.或

B..将常量替换为其值.例如

B. Replace the constants with their values.. For Example

With objExcelAssist.Worksheet.Columns("N:N")
    .HorizontalAlignment = 5
    .VerticalAlignment = -4107
    .WrapText = False
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = -5002
    .MergeCells = False
End With

这篇关于horizo​​ntalAlignment不适用于xlFill的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 22:05