+ Reply to Thread
Results 1 to 15 of 15

Print using Add-in Only (Excel 2010, VBA)

  1. #1
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Print using Add-in Only (Excel 2010, VBA)

    I am trying to disable the PRINT function being used be separate workbooks. The only time I want it to print is using an AddIn. I have attached an example. It shows the messagebox but then allow the Excel Print function to work without using the AddIn. Additionally, the AddIn is getting the messagebox.

    Book1 in ThisWorkbook
    Please Login or Register  to view this content.
    AddIn Code (partial)
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Print using Add-in Only (Excel 2010, VBA)

    If you never want to allow normal printing from that workbook then just use:

    Please Login or Register  to view this content.
    I don't see the need for the global variable PrntOK.

  3. #3
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Print using Add-in Only (Excel 2010, VBA)

    In fact, why not do this:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Then you effectively cancel normal printing, and do the add-in printing instead, without the necessity for an error message.

  4. #4
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Print using Add-in Only (Excel 2010, VBA)

    I am not following what you're saying or how to place the code. In short, the problem is that I have several workbooks (20+) that run macros running calculations. People are printing directly from those workbooks (which is what I want to stop). I want them to use the AddIn that I created to print (as it saves into .PDF into a specific format). This is why I wanted to place the code disabling printing into these 20+ workbooks using a public sub so I could pass the boolean value of True from the AddIn so it would print from the AddIn.

    Not sure that was the best way, but the only way this novice could devise. Alas, the code does not work.

  5. #5
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Print using Add-in Only (Excel 2010, VBA)

    I'm assuming that you are able to insert code in those 20 workbooks to implement this. These were just replacements for your existing routines of the same names.

    When any user attempts to print, the default print job instruction will be ignored (Cancel = True). But at the same time your PrintDoc routine is called instead. So the user presses print, and gets a printout, except via your add-in. So they do not even have to be aware that there is an add-in; all printing will be sent to it without their being aware.

  6. #6
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Print using Add-in Only (Excel 2010, VBA)

    "So the user presses print, and gets a printout, except via your add-in"

    I am trying to make it so the can ONLY print by using the print Macro in the AddIn. They are already aware of the print macro in the AddIn but are not utilizing it. They use the default print job instruction which is what I am trying to prevent and force them to use the AddIn.

  7. #7
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Print using Add-in Only (Excel 2010, VBA)

    That's exactly what it does. They will TRY to print normally, but it prints via the add-in instead. You've removed their normal print function, and effectively taken away their choice. Am I missing something? Do they have to press a button in your add-in to print? I've assumed that the PrintDocX routine prints.

  8. #8
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Print using Add-in Only (Excel 2010, VBA)

    I apologize for the confusion.

    Yes, there is a print button in the Add In. The addin creates a menu toolbar with dropdown options. One of the dropdown options is to PRINT via the addin. The dropdown print option runs the PrintDocX
    Last edited by lloydgodin; 08-03-2015 at 03:33 PM. Reason: clarification

  9. #9
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Print using Add-in Only (Excel 2010, VBA)

    Thread bump

  10. #10
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Print using Add-in Only (Excel 2010, VBA)

    Sorry, been/am busy. Will get back to you.

  11. #11
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Print using Add-in Only (Excel 2010, VBA)

    No worries. I understand. Was just bumping to see if there were others who might have something to add.

  12. #12
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Print using Add-in Only (Excel 2010, VBA)

    I am really confused, what actually happens when
    Please Login or Register  to view this content.
    is called?

    Does it print immediately or does it bring up a UI/Dialog?

    I understood that you were originally asking for this behaviour:

    • User wants to print, so clicks the Excel print button
    • Your messagebox comes up and tells them they can't print this way
    • They must now go to the add-in and start printing from there

    I was suggesting this behaviour:

    • User wants to print, so clicks the Excel print button
    • We've hijacked the Excel print button, so we can do anything now, so we cancel his 'normal' print request. Now rather than complain at him, just do what he asked, print.
    • So call the PrintDocX routine, and start printing immediately.

    Of course if Call PrintDocX isn't actually an instruction to start printing, then that's why I've been confused.

  13. #13
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Print using Add-in Only (Excel 2010, VBA)

    The PrintDocX(name, ctrlNbr) is a function that passes the name & ctrlNbr to another set of instructions that is indeed an instruction to print immediately though it is code to save as a .PDF with a prescribed naming convention. The reason I want the behavior suggested is my users are not saving their files in the prescribed naming covention that I want used. So I do not want them to print normally but be forced to use my AddIn to print.

    The previously attached files should better give an idea of what I am looking for. Each of the workbooks will contain the code necessary to disable the Excel print function, unless they use the AddIn. The AddIn creates a toolbar that has dropdown list selection, one of which has the code to call the PrintDocX routine.

  14. #14
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Print using Add-in Only (Excel 2010, VBA)

    I've already explained how my suggested way disables normal printing and performs add-in printing instead.
    Is it imperative that they interact with the dropdown interface?
    I don't understand why you don't prefer the way without the extra steps.

  15. #15
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Print using Add-in Only (Excel 2010, VBA)

    I am not a programmer by nature. I prefer to be able to see what the code is in the actual sheets. I am sorry I was not able to follow your examples

    Yes, it is imperative they work with the dropdown interface.

    It may seem like an extra step but it is necessary the way we do things at the company here.

    Appreciate the help. Thank you for your time.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 05-20-2015, 07:23 PM
  2. Excel 2010, Excel 2013 BeforePrint Event Trigger (Before Print Preview)
    By mikepfly2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-13-2015, 03:43 PM
  3. Excel 2007/2010 Print Macro
    By Cansa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2014, 11:35 PM
  4. Disable Print Preview in Excel 2010
    By Sophie.Durrant in forum Excel General
    Replies: 1
    Last Post: 12-21-2012, 05:53 PM
  5. Excel 2010 Print Command
    By Tendon in forum Excel General
    Replies: 1
    Last Post: 06-16-2011, 02:35 AM
  6. Excel 2010 print/print preview error for combo boxes
    By dlmcdan in forum Excel General
    Replies: 3
    Last Post: 03-23-2011, 12:32 PM
  7. Excel 2010 Print Preview
    By diesellam in forum Excel General
    Replies: 0
    Last Post: 03-09-2011, 04:07 PM

Tags for this Thread

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