XPS Automate file save as

DFragnDragn

Board Regular
Joined
Mar 6, 2010
Messages
81
This .XPS bloc works perfectly, but is currently running a manual save feature to the end user.
I've tried everything in my knowledge base and a several hours on the net.

I prefer to automate the save function and nest it with the balance of the wb dir files.
Any ideas greatly appreciated.

Code:
Option Explicit

Sub Ledger1()
    On Error Resume Next
    With ActiveSheet
        Columns("S:W").EntireColumn.Hidden = False
        Call PasteAll4Print
        On Error Resume Next
        Dim LastPrintRow As String
        Dim LastLine As Long
        Dim PrntCopy As String
        LastLine = Range("S350").End(xlUp).Row
        LastPrintRow = ("S1") & ":W" & LastLine
        PrntCopy = LastPrintRow
        With Worksheets("Sheet1").PageSetup
            .CenterHorizontally = True
            .PrintArea = PrntCopy
            .Orientation = xlPortrait
        End With
        Range(PrntCopy).PrintOut Copies:=1
        Application.CutCopyMode = False
    End With
    ActiveSheet.Range("M1").Select
    Columns("S:W").EntireColumn.Hidden = True
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Just replace...

Code:
Range(PrntCopy).PrintOut Copies:=1
with
Code:
Range(PrntCopy).Select
Selection.ExportAsFixedFormat Type:=xlTypeXPS, _
Filename:=ActiveWorkbook.Path & "\PrintOut.xps", _
Quality:=xlQualityStandard, IncludeDocProperties:=False, _
IgnorePrintAreas:=False, From:=1, To:=1, _
OpenAfterPublish:=True
 
Upvote 0

Forum statistics

Threads
1,214,413
Messages
6,119,372
Members
448,888
Latest member
Arle8907

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