In the spirit of computers never needing more than 640k, Micro$oft, in their supreme wisdom, made integers in vbs both slow and having a maximum value of only 32,767. Therefore, my ms word vbs code gives a 'runtime error 6' when I have more than 32,767 paragraphs in the word document. Obviously, I need to convert my vbs code to handle a larger number of paragraphs.
What I've learned after hitting google and searching a little in this forum is that I need to do a global replace of "Integer" with "Long". But even after doing that, the script crashes word without any error, as I am using the "on error" command. (Even though it is an atrocious solution, it is the fastest IMO.)
Question, which lines below need to be changed? To reduce the # of lines to be reviewed, I've removed duplicated lines and the lines I am sure are not the problem.
Code:Dim Reds As Integer Dim counter As Integer Dim SBar As Boolean Dim TrkStatus As Boolean Dim eTime As Single Dim oParRef As Paragraph Dim oParChk As Paragraph Dim numberofparagraphsindoc As Integer numberofparagraphsindoc = ActiveDocument.Paragraphs.Count Reds = 0 Set oParChk = oParRef.Next counter = counter + 1 Loop Until oParRef Is Nothing If oParRef.Range = oParChk.Range Then oParChk.Range.Delete Reds = Reds + 1 Set oParChk = oParChk.Next If Len(oParRef.Range.Text) > 1 Then Loop Until oParChk Is Nothing Set oParRef = oParRef.Next Set oParChk = oParRef.Next Set oParRef = ActiveDocument.Range.Paragraphs(1) ActiveDocument.TrackRevisions = TrkStatus eTime = Timer
The red code is now "Long." What else need to be changed? Do I need a command like
?Code:Dim oParRef As LongParagraph
Jason


Reply With Quote

