Excel中PrintArea的最大字符串长度是多少?

6

Excel 2003和2010中PrintArea的最大字符串长度是多少?

我的PrintArea字符串长度为677。

这在Excel 2003中会引发错误,但在2010中不会,因此我想知道在这两个版本以及2007中的最大字符串长度是多少。

1个回答

4

2003和2007版本的字符限制是255。

我没有2010的副本来测试,但你可以使用这个VBA代码轻松测试它。只需运行宏,在它崩溃后进入Debug,并检查i的值。比该值少一的将是最大字符串长度。

Sub PrintRangeTest()

    Dim i As Integer
    Dim j As Integer
    Dim newName As String
    newName = ""
    Dim rng As Range

    For i = 1 To 100000 //some arbitrarily large number
        newName = ""
        For j = 1 To i
            newName = newName & "a"
        Next

        Set rng = ActiveSheet.Range(Cells(1, 1), Cells(i, i))
        rng.Name = newName

        ActiveSheet.PageSetup.PrintArea = rng
    Next

End Sub

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接