+ Reply to Thread
Results 1 to 12 of 12

Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

  1. #1
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    Good day,
    I have set up in my "ThisWorkbook" the following code:

    Please Login or Register  to view this content.
    This code seems to work when it want's to. In my Sheets("Control").Range("A2").Value I have a list of name that when I double click a userform with a combobox selection is introduced. But when I add another user into to my Sheets("Control").Range("A2") and then print...it will take the previous name that was in there...

    What Am I doing wrong here?
    Click the star icon in the lower left part of the contributor's post and add Reputation if we have helped you .

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    Nothing obvious. Does your other code disable events anywhere?
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    I have this in my Userform:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    And I have this in another userform for the name selection:
    Last edited by Excelnoub; 06-16-2014 at 09:02 AM.

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    How does A2 get populated?

  6. #6
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    By either entering by hand or double clicking the cell A2:

    Please Login or Register  to view this content.
    I mean when I look at the Print Preview it will make it the value in A2 from my Control Sheet but when it prints it will still mentioned the previous user...

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    There's nothing in any of your code that mentions A2. Is it linked to the combobox control directly?

  8. #8
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    No it as follows:

    The user will sometime change, therefore I have a Control Sheet that, in A2 either the user Double-Clicks or add the user by Hand, if d-c, then a userform will pop up with the following:

    Please Login or Register  to view this content.
    Therefore adding the selected name, from the userform, in the active cell, ActiveCell is A2.

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    I can't see anything wrong with the code so without the workbook I'm afraid I can't comment further.

  10. #10
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    Here is an example wkb

    Print.xlsm

    You need to select the Pre-Solicitation Sheet and click on the Print Cmd_Button "Print Options" and select the "Print All Sheets". If you print a name will be in the top left, that doesn't even match the name selected in sheet Control.
    Last edited by Excelnoub; 06-16-2014 at 10:05 AM.

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    Ah yes, I'd forgotten about this nice new feature. If you use the Backstage Print preview screen, the BeforePrint event won't run. If you print directly, or use the old full screen print preview, it does run. You'll need to run the page setup code from the code that updates A2, I think.

  12. #12
    Forum Contributor
    Join Date
    03-29-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    818

    Re: Private Sub Workbook_BeforePrint(Cancel As Boolean) Range Issue (2007)

    Thank you for the heads up...

    I have changed the sheets("Control") code to add:

    Please Login or Register  to view this content.
    Now it works

    Thank you for the tip...

+ 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. Workbook_BeforeClose(cancel As Boolean)
    By Vdogeek in forum Excel General
    Replies: 3
    Last Post: 05-23-2014, 12:39 PM
  2. Private Sub Workbook_BeforePrint(Cancel As Boolean) not executing procedures
    By Burrswood in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2013, 11:48 AM
  3. Private Sub Workbook_BeforePrint not working
    By Dutchbeer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-30-2013, 10:05 AM
  4. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) problem
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-29-2009, 07:28 PM
  5. Private sub worksheet_change(bval target as range) issue
    By Darren in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-17-2006, 08:10 AM

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