Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default cant read memory crash when printing

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default cant read memory crash when printing

Think I have solved the problem :-

I put a pause in the code prior to printing. Everything then worked ok.
Seemed to be excel started printing before excel had finished creating the
page to print and this caused the cant read from memory crash.

Strange but not going to argue, cause it works so far, touch wood.

Anthony

"Anthony" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros crash, "Not enough memory" CLR Excel Discussion (Misc queries) 9 February 13th 07 03:41 PM
Memory could not be read error Eddie Excel Discussion (Misc queries) 0 May 24th 05 01:15 PM
Useful Comment Concerning Memory Read/Write Errors Donna[_7_] Excel Programming 5 March 23rd 05 03:47 PM
Message--MEMORY COULD NOT BE READ mcrmike[_3_] Excel Programming 0 July 19th 04 09:30 PM
The instruction at "0x65255ac9" referenced memory at "0x00000008". The memory could not be read. Clikc OK to terminate etc Angus Comber[_2_] Excel Programming 1 November 7th 03 01:18 PM


All times are GMT +1. The time now is 07:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"