PC Review


Reply
Thread Tools Rate Thread

cant read memory crash when printing

 
 
Anthony
Guest
Posts: n/a
 
      17th Mar 2008
I am writing VBA on a works computer, so I dont have admin rights etc on the
machine, so any solutions need to take that into account. The workbook is
under 1mb even when populated and the code runs in single step mode and 9
times out of 10 when run normally, but from time to time excel crashes with
a cant ready memory error at the point of me printing.

I have re-coded a whole section of the printing routine to stop the
execution of events loading info prior to print and that solved alot of the
crashes and it now works 9 times out of 10. I have also ensured every
userform is unloaded after use and there are no duplicate unloads.

The print code is very simple for the section excel falls over in. It tests
to see if the user has selected an entry from a list box, hides the listbox,
loads page with info, selects the page, prints, tests to see if the user
wants a letter, selects letter page, prints letter the no. of times set on
user form.

I am using excel 2000.

code:-

Private Sub cbSelected_Click()

Dim lItem As Long

ufAnimal_List.Hide

For lItem = 0 To Me.lbAnimal_Selection.ListCount - 1

If Me.lbAnimal_Selection.Selected(lItem) = True Then

Worksheets("animal Card").Range("B16").Value =
Worksheets("workpage").Range("BV" & _
(7 + lItem)).Value
Worksheets("animal Card").Range("B23").Value =
Worksheets("workpage").Range("BW" & _
(7 + lItem)).Value
Worksheets("animal Card").Range("B23").Value =
Worksheets("animal Card").Range("B23").Value + _
". " + Worksheets("workpage").Range("CF" & Search_Line("CE",
_
Worksheets("workpage").Range("CG5").Value, _
Worksheets("workpage").Range("BS" & (7 +
lItem)).Value)).Value

Worksheets("Animal Card").Select

'ActiveSheet.PrintPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1

'If print letter option selected then print letter
If (Worksheets("workpage").Range("G61").Value = True) Then

Worksheets("Animal Letter").Select
'Print no. copies of letter one for customer and other for
walk log
ActiveWindow.SelectedSheets.PrintOut
Copies:=Val(Me.tbCopies.Text)

End If

Me.lbAnimal_Selection.Selected(lItem) = False

End If

Next lItem

End Sub

Any ideas on why it would be crashing when printing?

Anthony


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mystery Vista Used Memory grows until Out of Memory and crash - howto diagnose? hogwell Windows Vista Performance 0 13th Apr 2009 09:20 PM
Attempted to read or write protected memory. This is often anindication that other memory is corrupt Venu Microsoft C# .NET 1 28th Mar 2008 07:13 PM
"Memory cannot be Read" Error,...Crash Kevin T. Mahoney Microsoft Windows 2000 Windows Updates 3 25th Jul 2007 02:10 PM
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Dhruba Bandopadhyay Microsoft ASP .NET 0 12th May 2006 02:24 PM
Excel 97 crash: "Memory could not be read" DG Microsoft Excel Crashes 1 2nd Dec 2003 07:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:06 AM.