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
 

rlv01

Well-known Member
Joined
May 16, 2017
Messages
809
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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)" ?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

rlv01

Well-known Member
Joined
May 16, 2017
Messages
809
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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.
 

cocobeans

New Member
Joined
Jul 8, 2020
Messages
10
Office Version
  1. 365
Platform
  1. MacOS
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.
 

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,893
Office Version
  1. 2013
Platform
  1. Windows
You could look at the feasibility of creating an AppleScript to set the default printer and then run that from VB.

 

Watch MrExcel Video

Forum statistics

Threads
1,130,425
Messages
5,642,042
Members
417,251
Latest member
Dordrecht

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