+ Reply to Thread
Results 1 to 16 of 16

Print Blanks

  1. #1
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Print Blanks

    I'm trying to print a selection, using the macro below. The printer responds but just sends a sheet through with no printing on it. The printer prints from other macros ok, but the other macros don't include the With or If statements.
    Any ideas what's happening and why ?

    Please Login or Register  to view this content.
    Last edited by NBVC; 12-22-2009 at 09:00 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Printing Blanks

    Macro4 is not a great way to go.

    This should work

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Printing Blanks

    Hi,
    I tried selection.printout but got an error message:-
    "Object doesn't support this property or method"
    Do I have to download an add-in or something ??
    Charles.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Printing Blanks

    A good way to look at the code that will work is to use the macro recorder.
    Start the recorder, select a range, go to File=>print and check selection, then print.
    Stop the macro recorder and then look at the code.
    Incorporate that code into the rest of your code.

  5. #5
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Printing Blanks

    Hi Dave,
    Many thanks for your reply.
    I am able to get the macro to print, but I have a problem when I attempt to make the printing conditional on cell values, in an If statement. Looking through the forum, I haven't been able to locate any code which achieves this. The code I have copied just doesn't work (error messages as per my last reply).
    I'm surprised that this is not a more discussed issue; programming in general is about taking data in, then churning it out in other format - I would have thought that printing would have been one of the more important outputs of a programme. Perhaps VBA just isn't up to the mark in this area ?
    Best regards,
    Charles

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Printing Blanks

    Lets see the code you ended up with.

  7. #7
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Print Blanks

    Hi Dave,
    This is the code I fionished up with - still printing blank sheets. The macro is in sheet1.

    <code>
    Sub OptionButton1_Click()
    With Sheets("Sheet2")
    If Range("k1") = 1 And Range("k2") = 1 Then

    Range("a1:j50").Select
    Else
    If Range("k2") = 2 Then

    Range("a1:j100").Select

    End If

    Selection.Select
    Selection.PrintOut


    End If
    End With
    End Sub
    <code>


    Best regards,
    Charles

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Print Blanks

    Hello,
    What happened to the code from the macro recorder?

  9. #9
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Print Blanks

    Hi again,
    How do I record a macro with an If statement in it ?
    Best regards,
    Charles

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Print Blanks

    Try this

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Print Blanks

    Thanks again - but - I get an error message " Can't find project or library" and the egg-timer does not quit. Pressing OK stops the eggtimer.
    Then, when I try to edit the macro, before I can see the code, the same error message is displayed..so I have no choice but to delete the option button, and start a new one typing in the code, checking I've not made any errors, to get the same message and inaccessability to the code again.
    Did you try it ? Am I possibly missing a DLL or something ?
    Best regards,
    Charles

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Print Blanks

    why is it an option button?
    Sub OptionButton1_Click()
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Print Blanks

    I did not even notice it was an option button, I was looking more at the code.
    Place the code in a regular button

  14. #14
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Print Blanks

    Hi all,
    I changed the button to a regular one and used the code as per message number 10 above, but nothing happened. Thanks for all your help and interest in my prob.
    I have to mention that I have a solution now, that I got from a website - if anyone's interested, search google for "conditional printing" there are 3 sets of coding to do the job.
    Once again, I much appreciate your help.
    Charles.

  15. #15
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Print Blanks

    Can you supply a link to your solution?

  16. #16
    Registered User
    Join Date
    09-21-2009
    Location
    Lincolnshire, England
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Print Blanks


+ 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