I am trying to rename a PDF that has been exported from a workbook.

Mwill15g

New Member
Joined
Jan 14, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
I have the following code in place now but instead of overwriting the pdf in the file location I want to add a date to the name. That way I can go back and see previous file that have been ran before. I am completely green to this so any help or advise would be welcomed.

ChDir "S:\WWWW\To_MdSt"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

"S:\WWWW\To_MdSt\XXXX\OOOO", Quality:=xlQualityStandard, _

IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _

True
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this:
VBA Code:
ChDir "S:\WWWW\To_MdSt"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

"S:\WWWW\To_MdSt\XXXX\OOOO" & format(Date, " mm-dd-yyyy") & ".pdf", Quality:=xlQualityStandard, _

IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _

True
 
Upvote 0
Solution
@BigDawg15 Nailed it! It worked perfect! I have been playing around with this for way too long! Appreciate it! GoVols!
 
Upvote 0
Try this:
VBA Code:
ChDir "S:\WWWW\To_MdSt"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

"S:\WWWW\To_MdSt\XXXX\OOOO" & format(Date, " mm-dd-yyyy") & ".pdf", Quality:=xlQualityStandard, _

IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _

True
Try this:
VBA Code:
ChDir "S:\WWWW\To_MdSt"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

"S:\WWWW\To_MdSt\XXXX\OOOO" & format(Date, " mm-dd-yyyy") & ".pdf", Quality:=xlQualityStandard, _

IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _

True
Quick question, if I wanted to export it as an excel instead of a PDF what would I need to change?
 
Upvote 0
Try:

VBA Code:
Sub SaveSheet()
ActiveSheet.Copy
With ActiveSheet.UsedRange
.Copy
.PasteSpecial xlValues
.PasteSpecial xlFormats
End With
Application.CutCopyMode = False
Dim DTAddress As String
DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
ActiveWorkbook.SaveAs DTAddress & Range("E19") & " " & Format(Date, "mmmmddyyyy") & " " & Format(Time, "HHMM"), FileFormat:= _
xlNormal
End Sub
 
Upvote 0
Something like this:

VBA Code:
Activesheet.Copy   'creates an independent copy of the activesheet
 
Activeworkbook.SaveAs "C:\SomeFolder\SomeFileName.xls", FileFormat:=xlWorkbookNormal   'save workbook created above
 
Activeworkbook.Close  'close it and return to original workbook
 
Upvote 0

Forum statistics

Threads
1,214,385
Messages
6,119,210
Members
448,874
Latest member
b1step2far

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