.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!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Welcome to MrExcel Message Board.
Please upload your macro here to check.
Are your Preview:=TRUE at your code.
 
Upvote 0
Also Check This:

Instead of
ActiveWindow.SelectedSheets.PrintPreview

use
Application.CommandBars.ExecuteMso "FilePrintPreview"
 
Upvote 0
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?
 
Upvote 0
Also test:
PrintSheets.Printout Preview:=True
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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