Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

cant read memory crash when printing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Anthony - 17 Mar 2008 21:44 GMT
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
Anthony - 18 Mar 2008 19:46 GMT
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

>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
[quoted text clipped - 69 lines]
>
> Anthony
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.