After saving a pdf with one macro . Another macro will no longer PrintOut

cocobeans

New Member
Joined
Jul 8, 2020
Messages
10
Office Version
  1. 365
Platform
  1. MacOS
Hello , After I use the Macro titled SaveRangeAsPDF the macro titled Printestimate will not Printout to the printer .When I run the subs in this order the PrintEstimate sub will quickly show a box that says processing but the printer icon does not show 1 and nothing prints.

If I use the PrintEstimate sub before the SaveRangeAsPDF I can use it as many times as I want with no issue and it works perfectly.

Ideally I would like to combine these two subs into one and be able to run it as many times as I want. This is due to me changing data and then wanting to save pdf and printout .
Any help would be greatly appreciated.

Sub SaveRangeAsPDF()

Dim saveLocation As String
Dim rng As Range

With ActiveSheet.PageSetup

.Orientation = xlPortrait
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
'This is the file destination and range
saveLocation = "/Users/boauman/Desktop/Bobs Personal/Estimate pdf/"
Set rng = Range("$A$108:$F$160")


'Save a range as PDF
rng.ExportAsFixedFormat Type:=xlTypePDF, _
FileName:=saveLocation & Range("B1").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False


ActiveSheet.PageSetup.Zoom = 87

End Sub


Sub Printestimate()

With ActiveSheet.PageSetup

.Orientation = xlPortrait
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Application.Goto Reference:="ESTIMATE"
ActiveSheet.PageSetup.PrintArea = "$A$108:$F$160"

Range("A108:F160").Select
ActiveSheet.PageSetup.PrintArea = "$A$108:$F$160"
Selection.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.Zoom = 87
End Sub
 
You said earlier:
PrintEstimate sub before the SaveRangeAsPDF I can use it as many times as I want with no issue and it works perfectly.

If during the time it works perfectly, you executed this line of code:

VBA Code:
MsgBox  Application.ActivePrinter

Would it still return "unknown printer (check your Control Panel)" ?
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I don't have any other suggestions to offer. It sounds to me like this is a problem specific to MAC VBA and I don't have that setup.
 
Upvote 0
No problem,thanks a lot for your help. I have come up with a workaround by opening the print dialog box with the print macro . It makes for an extra step but at least it works.
 
Upvote 0
You could look at the feasibility of creating an AppleScript to set the default printer and then run that from VB.

 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

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