+ Reply to Thread
Results 1 to 4 of 4

Print Macro with a 1004 Run Time Error

  1. #1
    Registered User
    Join Date
    07-21-2011
    Location
    Baton Rouge, Louisiana
    MS-Off Ver
    Excel 2007
    Posts
    19

    Print Macro with a 1004 Run Time Error

    I Recorded a macro that would allow me to print the charts in sheet 2, but upon running the macro, I got a 1004 runtime error.

    I looked at the debugging code and saw the last line was the problem.

    How do I fix it?

    Code from VBA Editor:
    Please Login or Register  to view this content.

    Excel Macro Help 1.xlsm
    Last edited by derivative_x; 09-21-2012 at 12:42 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Print Macro with a 1004 Run Time Error

    You need to add code tags to your code sample above.

    Assuming you do that, remove all the " Application.PrintCommunication = True/False" statements.

    My understanding is that it is supposed to stop constant chatter with the printer to speed things up but I'm not sure it works ... or which version of Excel it should work in. Anyway, ditch it. And get rid of all the lines where you are accepting defaults for things you never change. For example, if you have never set the footers, get rid of all the xxxFooter.Text statements. That will make it quicker.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Print Macro with a 1004 Run Time Error

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.

    Sorry TMS. I didnt refresh (again).
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: Print Macro with a 1004 Run Time Error

    @Arlette: no worries ...but you've only tagged the first line of code.

    @derivative_x: that option came in in 2010 and your profile says 2007 (it doesn't work for me on 2007, fair enough).

    I believe that "IgnorePrintAreas" is incompatible with printing a selection, so just remove it.

    Regards, TMS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1