View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Tim Rush Tim Rush is offline
external usenet poster
 
Posts: 27
Default Excel Crash in procedure.

Update:
It appears that Excel does its crash during the write evolution. Stepping
through the procedures line by line, its always the same point, and appears
at the write statement.
Peter, I even tried using the shorter procedure you wrote with same effect.

So, perhaps its a library routine I've reference? My Reference list has
several 'Visual Basic for Applications' each using a different .dll file.
Which is the best to use, or which do you guys use? And perhaps to do this I
need another particular one. At the moment I have the following turned on.
Visual Basic for Applications
Microsoft Excell 11.0 Object Library
OLE Automation
Microsoft Office 11.0 Object Library
Microsoft VBScript Regular Expressions 5.5
Microsoft Visual Basic for Applications Extensibility 5.3



"Peter T" wrote:

Way back I vaguely recall Rob Bovey's highly respected Code Cleaner causing
similar problems while writing (stripping code) to Object modules in
'another' project. Seemed to be a relatively rare and intermittent bug. I
think Rob may have introduced various pauses and DoEvents at appropriate
times to slow things down, which I think solved a significant proportion of
the problems. I don't think even that prevented 100% of problems why not but
not give it a shot.

Private Declare Sub Sleep _
Lib "KERNEL32.DLL" (ByVal dwMilliseconds As Long)

to pause say half a second
Sleep 500

perhaps also add a DoEvents

Add a sleep (or maybe an application.wait) and DoEvents before & after
writing the lines.

In passing, I don't see any reason to use FSO, why not read directly, eg

Sub GetTextByLines()
Dim LineNo As Long
Dim iFF As Integer
Dim Source As String, EntryLine As String
iFF = FreeFile

Close iFF ' just in case not previously closed

Source = "Y:\Quality\ovlSetup\" & module & ".txt"

On Error GoTo errH
Open Source For Input Access Read As #iFF
On Error GoTo 0

Do While Not EOF(iFF)
LineNo = LineNo + 1
Line Input #iFF, EntryLine
Debug.Print LineNo; EntryLine
Loop

errH:
Close iFF
If LineNo = 0 Then MsgBox Source & " not found"
End Sub


Regards,
Peter T