在Office 64位中有大约10k段错误的Word文档 [英] Word document having around 10k paragraphs throwing error in Office 64 Bit
问题描述
在64位办公室中,当尝试在具有10K或更多段落的word文档上执行以下VBA代码时,它会抛出"Out of Stack Error" 28 QUOT;消息框。
In 64 Bit office, when trying to execute following VBA code on a word document having 10K or more paragraphs, it is throwing "Out of Stack Error 28" message box.
公共职能ParagCount()
D as a As Word.Paragraph
Dim b As Word.Paragraph
Dim i As Integer
设置a = ThisDocument.Paragraphs.First
对于i = 1到9999
设置b = a.Next
设置a = b
下一个
设置b = ThisDocument.Paragraphs .Item(10000)
设置a = b
结束功能
Public Function ParagCount()
Dim a As Word.Paragraph
Dim b As Word.Paragraph
Dim i As Integer
Set a = ThisDocument.Paragraphs.First
For i = 1 To 9999
Set b = a.Next
Set a = b
Next i
Set b = ThisDocument.Paragraphs.Item(10000)
Set a = b
End Function
有人可以指出问题或让我知道替代方法吗同样的?
Can somebody point out the problem or let me know the alternative approach to do the same?
谢谢
Uttam
推荐答案
嗨Uttam,
Hi Uttam,
我认为这可能是由于内存不足造成的?我可以在我的系统上重现它。
I think this might be caused by a lack of memory? I could reproduce it on my system.
为什么你需要在循环中'设置a = b'?
如果删除这一行,代码运行很好。
Why do you need 'set a= b' in the loop?
If you delete this line, the code runs fine.
如果你需要另一种方法,你想用这段代码做什么?
If you need another approach, what is it that you want to archieve with this code?
一切顺利,
Astrid
这篇关于在Office 64位中有大约10k段错误的Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!