Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word VBA Goes into BREAK w-out Reason

Status
Not open for further replies.

Quehay

Programmer
Feb 6, 2000
804
0
0
US
I've got some simple Word VBA that worked fine in a couple of docs, but now it goes into BREAK mode on every iteration (with no errors). What gives? TIA

Sub RevisionsToTextFile()
On Error Resume Next
Dim Rev As Revision
Dim intFreeFile As Integer
Dim lngRevCount As Long, i As Long
intFreeFile = FreeFile

lngRevCount = ActiveDocument.Revisions.Count
Open "C:\Documents and Settings\robertsjeff\My Documents\revs8-9.txt" For Append As #intFreeFile

Print #intFreeFile, "Total Revisions: " & Str(lngRevCount)
For i = 1 To (lngRevCount - 1)
Print #intFreeFile, Str(ActiveDocument.Revisions(i).Index) & " " & ActiveDocument.Revisions(i).Range


Next
Close #intFreeFile
MsgBox "done"
Set Rev = Nothing

End Sub 'RevisionsToTextFile


Jeff Roberts
Insight Data Consulting
Access and SQL Server Development
 
Try to comment out the On Error Resume Next instruction to get more info.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV...you know, I put that in there as a potential fix--it was doing so prior ;-)

I've seen this before with Word. I didn't try a reboot, so I wonder if stepping through with F8 set some session property that's causing this.


Jeff Roberts
Insight Data Consulting
Access and SQL Server Development
 
Oh - resume next doesn't handle errors, it just continues regardless of errors;-)

Perhaps check the Error Trapping in Tools | Options - General tab (in VBE) -> Break on unhandled errors.

If it's no error, I've sometimes seen similar, both in Word and Access, when the yellow line highlights either a line where I've had a breakpoint or where an error occured previously. I think, but I'm not entirely sure, it happened when running code which where not compiled/saved.

In such cases, doing a small alteration, then compile/save often resolved the issue. Else try exporting and importing the module.

Roy-Vidar
 
Thanks Roy. I tried those too (I set break on all errors to true to confirm that no errors were occurring and reset to break on unhandled; save VBA project and compile.)
Sounds like you suspect the same sort of thing (a residual code project property from having a break point in place).

I'll try re-importing. I've been storing this in the Normal template module, maybe it should be a separate module. Word was having problems saving the code due to a second open document having a connection to Normal.

If I figure this out I'll post.


Jeff Roberts
Insight Data Consulting
Access and SQL Server Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top