开发者

Maximum String Length of PrintArea in Excel

What is the maximum string length of PrintArea in Excel 2003 and 2010?

I have a PrintArea string length of 677.

This throws an error in Excel 200开发者_如何学Python3, but not in 2010, so I'd like to know what the maximum string length is in both versions as well as 2007.


The limit in 2003 and 2007 is 255 characters.

I don't have a copy of 2010 to test, but you can use this VBA code to test it easily. Just run the macro and after it crashes, go to Debug, and check the value of i. One less than that will be the maximum string length.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜