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

A Thayuman

New Member
Joined
Mar 6, 2019
Messages
30
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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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