Printing Problems Color Change

HardAtWork

Board Regular
Joined
Sep 17, 2010
Messages
52
Here's my problem...thought hard about it and now I'm stuck.

I have a workbook that has a dark and a light mode. Ie. Dark mode the background is black and letters are white...and Light mode is the opposite.

Within the sheets there are numerous things that are selected to change color also...along with the font and background.

The user needs to print the document but in light mode even if the screen is in dark mode.

I have the following code to work when printing.

Private Sub Workbook_BeforePrint (Cancel as Boolean)

ApplicationRun. "Light_Mode"
'Sheets change colors
Application.Ontime + TimeValue("00:00:05"), "After Print"
'After print is my dark mode so they can keep typing
End Sub

The problem is that if the user is on page two and hits print it changes the colors of the pages to light (good), but does not stay on the original page he was on (bad)...How can make the code remember what page they were on at the time of print, print that page, and then return to that page when the "After Print" is done running?

A little background on the light and dark mode. The page that appears right after the applicationRun is the last page of the workbook...which is the last page with code changes.

Main Question - Can I get the program to remember what page was selected at the time the print code was activated, change the colors, and return to that page to print the document?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
try this untested
Code:
Private Sub Workbook_BeforePrint (Cancel as Boolean)
dim sname as string
sname = activesheet.name
ApplicationRun. "Light_Mode"
'Sheets change colors
Application.Ontime + TimeValue("00:00:05"), "After Print"
'After print is my dark mode so they can keep typing
sheets(sname).activate
End Sub
 
Upvote 0
I have not been able to get the code to work as written; however, I changed it alttle and it work halfway.

I added the Sheets(sname).activate after the application.run "Light Mode"
so that it would stay on the correct page

then I have the applicationOntime coding followed by another sheets(sname).activate

However, it does not go to the same sheet as it does right after the light mode.

Do ya'll have another suggestion...the light mode and afterprint coding is completely the same other than the number to change the colors.
 
Upvote 0
I think I have found the ansner. I had to put the same code string in the "AfterPrint sub to return to the same page

I still need to test it but it looks good so far.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top