Save File with same Name everytime and change Name of PDF and Save

A Thayuman

New Member
Joined
Mar 6, 2019
Messages
28
The Code below works fine I took it from one of the solved problems and Mr.Excel
However I am not sure how to change the file location to Save with as the fixed name "E-liteMaster" & ".xlsm"
And change the path shown below to :
save to "C:\Users\anil\Documents\E-lite Invoices and PDF"

I am unable to do so! May I request some advice and help please

Code that works with the existing Path is:

Sub PrintSave()


'saveprint Macro
'
'
Dim Path As String
Dim filename As String
Path = Environ$("Userprofile") & "\Inv" & " "
filename = Sheets("Invoice").Range("A5")
Sheets("Invoice").Select
ActiveWorkbook.SaveAs filename:=Path & "E-liteMaster" & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
Path & filename & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False


End Sub


Save and Print with location change1.JPG

IgnorePrintAreas:=False


End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi Guys, I have been trying to get this to work for the last two days, I put the request up for a solution and after looking at a few other solution on the subject on Mr. Excel and with a lot of trial and error got something that works well - all it needed was to take out Environ$ and the open and close parenthesis, still dont know how it all works but for now it will do!

Sub PrintSave()


'saveprint Macro
'
'
Dim Path As String
Dim filename As String

Path = "C:\Users\anil\Documents\E-lite Invoices and PDF" & "\Inv" & " "
filename = Sheets("Invoice").Range("A5")

Sheets("Invoice").Select

ActiveWorkbook.SaveAs filename:=Path & "E-liteMaster" & ".xlsm", _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
Path & filename & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,737
Messages
6,126,577
Members
449,318
Latest member
Son Raphon

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