.PrintPreview is printing directly instead of providing preview

phineas21

New Member
Joined
Dec 21, 2020
Messages
2
Office Version
  1. 365
Hello!

I have a spreadsheet that will run a macro to calculate values and then package everything for printing. The code is set to provide a print preview at the end of the macro using: .PrintPreview.

The result is this window pops up:
1608586236564.png


This works perfectly for me and for the majority of users. However, some users have reported that the macro is skipping the Print Preview stage and sending the file directly to their default printer and printing. I cannot figure out what could be causing this since it does not seem to be directly related to the VBA code. Is there perhaps a user setting on those peoples' computers that could be causing their excel to skip the preview even though the code specifically calls for a preview? Or any other ideas as to what could be causing the issue?

Thanks!
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,354
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Welcome to MrExcel Message Board.
Please upload your macro here to check.
Are your Preview:=TRUE at your code.
 

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,354
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Also Check This:

Instead of
ActiveWindow.SelectedSheets.PrintPreview

use
Application.CommandBars.ExecuteMso "FilePrintPreview"
 

phineas21

New Member
Joined
Dec 21, 2020
Messages
2
Office Version
  1. 365
Application.CommandBars.ExecuteMso "FilePrintPreview"
Hi Maabadi, thanks for the help! I tried the above and it also calls the print preview, but it does so only for the active sheet instead of the larger group of sheets. This is the section of the code that deals with the printing:


Set PrintSheets = ActiveWindow.SelectedSheets
For Each ws In PrintSheets
If (Range("flag_FirstRun").Value = 1) Or (ws.Name = "4-Values Page a1") Or (ws.Name = "4-Values Page b1") Then
With ws.PageSetup
.CenterHorizontally = True
.CenterVertically = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.RightFooter = Range("Version") & " Page " & "&P" & " of " & "&N "
End With
End If

Next ws
Range("flag_FirstRun").Value = 0 ' Set First Run flag to zero so as to not run formating after the first illustration calculation.

Application.ScreenUpdating = True

PrintSheets.PrintPreview
Application.ScreenUpdating = False

The weird thing is this code works perfectly for me and most users. One user who has been seeing the problem of skipping the preview and sending directly to the printer just sent me their copy of the spreadsheet, but when I run the code it works perfectly again. Do you know of any settings on the user's personal computer that could cause the same spreadsheet to behave differently than on my computer?
 

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,354
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Also test:
PrintSheets.Printout Preview:=True
 

Watch MrExcel Video

Forum statistics

Threads
1,123,230
Messages
5,600,424
Members
414,383
Latest member
kevinlarey

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
Top