Print specific sheets seperately to printer and PDF

vlacombe

New Member
Joined
Oct 4, 2019
Messages
31
Is this doable and could someone suggest a script?

(Script would need to be seperate)

1. Print sheets seperately without prompt to the default printer: only i
f the sheet contains the text: "PrixMax" "6po" "Quote" (Then print them, else ignore)

2. Create a PDF per sheet
(If sheet contains the text: "PrixMax" "6po" "Quote" Then create a PDF for each, else ignore) without prompt (like using the microsoft print to PDF "printer" even though it's not the default printer, and send the file(s) and to a specific path written in the script... like a folder on the desktop. Script can use the sheet name as file name and I would want it to overwrite the PDF file if one is existant.


 
It doesn't work...

I can see the system loading as if it is working on something, however none of the files are being created in the same folder as of my current workbook, unlike the previous version you suggested. :(
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
The editor removed the Backslash.
Try this please

Code:
Sub Print_sheets()
  Dim sh As Worksheet, i As Long, shs As Variant, w2 As Workbook, sh2 As Worksheet
  Application.ScreenUpdating = False
  Application.DisplayAlerts = False
  shs = Array("PrixMax", "6po", "Quote")
  For Each sh In Sheets
    For i = 0 To UBound(shs)
      If LCase(sh.Name) Like "*" & LCase(shs(i)) & "*" Then
        Set w2 = Workbooks.Add
        Set sh2 = w2.Sheets(1)
        sh.Cells.Copy
        sh2.Range("A1").PasteSpecial xlPasteValues
        sh2.Range("A1").PasteSpecial xlPasteFormats
        w2.SaveAs Filename:=ThisWorkbook.Path & "[B][COLOR=#0000ff]\[/COLOR][/B]" & sh.Name & ".xlsx"
        w2.Close False
        Exit For
      End If
    Next
  Next
End Sub
 
Upvote 0
Hi Dante

It did fix the cells with formula but created other problems.
Somehow it changed my sheet format.

I found an alternative solution for me to deal with the formula issue. I changed it before the saving even occurs. It's not ideal for me but the final result is the same.

Thanks a lot for your time
 
Upvote 0

Forum statistics

Threads
1,224,748
Messages
6,180,721
Members
452,995
Latest member
isldboy

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