DFragnDragn

Board Regular
Joined
Mar 6, 2010
Messages
81
Hi, I'm trying to prevent xps overwrite on save.
I can't get anything to work. I'd prefer to use a variable value to individualize each save.
Is it even possible?

Code:
With ActiveSheet        
    .ExportAsFixedFormat _                
        Type:=xlTypeXPS, _                
        Filename:="C:Attempt\& Test.xps", _                
        OpenAfterPublish:=False    
End With
 
Last edited by a moderator:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try this...


Code:
[COLOR=#d3d3d3]'[/COLOR][COLOR=#a9a9a9]
[/COLOR][COLOR=#d3d3d3]'[/COLOR][COLOR=#a9a9a9][B]usage: SaveFileAsXPS("D:\XPSTestExport.xps")[/B]
[/COLOR][COLOR=#d3d3d3]'[/COLOR]
[COLOR=#ff0000][SIZE=3][FONT=arial narrow]Function[/FONT][/SIZE][/COLOR][COLOR=#ff0000][SIZE=3][FONT=arial narrow] SaveFileAsXPS[/FONT][/SIZE][/COLOR][COLOR=#0000ff][SIZE=3][FONT=arial narrow](ByVal paramFilename As String) As Boolean

[/FONT][/SIZE][/COLOR][COLOR=#a9a9a9][SIZE=3][FONT=arial narrow]'by lhartono[/FONT][/SIZE][/COLOR][COLOR=#0000ff][SIZE=3][FONT=arial narrow]
On Error GoTo Hell

    If Len(Dir(paramFilename)) > 0 Then
        paramFilename = vbNullString
        MsgBox "    File already exist.    ", vbInformation
        paramFilename = Application.GetSaveAsFilename(InitialFileName:="", FileFilter:="XPS Files (*.xps), *.xps", Title:="Save XPS as")
    End If
    
    If paramFilename <> "False" Then
        ActiveSheet.ExportAsFixedFormat Type:=xlTypeXPS, Filename:=paramFilename, OpenAfterPublish:=True
        SaveFileAsXPS= True
    End If
    
GetOut:
    Exit Function
Hell:
    MsgBox "Error #: " & Err.Number & vbNewLine & vbNewLine & Err.Description, vbOKOnly, "Error Save File as XPS"
    Resume GetOut

[/FONT][/SIZE][/COLOR][COLOR=#ff0000][SIZE=3][FONT=arial narrow]End Function[/FONT][/SIZE][/COLOR]
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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