ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Save with Worksheet as file Name (https://www.excelbanter.com/excel-programming/375499-macro-save-worksheet-file-name.html)

bbkixx

Macro Save with Worksheet as file Name
 
Hello-

I am trying to create a macro that will save a worksheet as a pdf, and
rename the file to the name of the selected worksheet. Now I have the saving
to pdf part down, but I can't seem to get the renaming of the filename to the
worksheet part down. Does anyone have some ideas how I can do this?

Any help will be greatly apperciated.

Thank you!
BBkixx

ufo_pilot

Macro Save with Worksheet as file Name
 
This is one that I use to save
In the original PNT031 sheet in A8 is =TODAY()
which is formatted to read each day ( 2006 Oct 19 )....
you can have the name of your worksheet in "A8
then between the " " put the path in.



Sub SvePNT031()
Dim strFileName As String
Sheets("PNT031").Activate
strFileName = Range("A8").Text
ActiveWorkbook.SaveAs Filename:="F:\Auditors.QA
references\2ndShift\JKPNT031\" & strFileName & ".xls"
ActiveWorkbook.Close
End Sub

"bbkixx" wrote:

Hello-

I am trying to create a macro that will save a worksheet as a pdf, and
rename the file to the name of the selected worksheet. Now I have the saving
to pdf part down, but I can't seem to get the renaming of the filename to the
worksheet part down. Does anyone have some ideas how I can do this?

Any help will be greatly apperciated.

Thank you!
BBkixx


NickHK[_3_]

Macro Save with Worksheet as file Name
 
Name "OldFileName.pdf" As "Newfilename.pdf"
Add the path as required.

NickHK

"bbkixx" ...
Hello-

I am trying to create a macro that will save a worksheet as a pdf, and
rename the file to the name of the selected worksheet. Now I have the
saving
to pdf part down, but I can't seem to get the renaming of the filename to
the
worksheet part down. Does anyone have some ideas how I can do this?

Any help will be greatly apperciated.

Thank you!
BBkixx




Charles Chickering

Macro Save with Worksheet as file Name
 
strFilename = "C:\YourPath\" & ActiveSheet.Name & ".YourExtension"
--
Charles Chickering

"A good example is twice the value of good advice."


"bbkixx" wrote:

Hello-

I am trying to create a macro that will save a worksheet as a pdf, and
rename the file to the name of the selected worksheet. Now I have the saving
to pdf part down, but I can't seem to get the renaming of the filename to the
worksheet part down. Does anyone have some ideas how I can do this?

Any help will be greatly apperciated.

Thank you!
BBkixx


Gary''s Student

Macro Save with Worksheet as file Name
 
I don't know how to SaveAs pdf, but the following will SaveAs the sheet or
(tab) name:


Sub Macro1()
Dim s As String
s = ActiveCell.Worksheet.Name
ActiveWorkbook.SaveAs Filename:=s
End Sub

You do not need to spec. the directory if you are willing to save back from
whence you came.
--
Gary's Student


"bbkixx" wrote:

Hello-

I am trying to create a macro that will save a worksheet as a pdf, and
rename the file to the name of the selected worksheet. Now I have the saving
to pdf part down, but I can't seem to get the renaming of the filename to the
worksheet part down. Does anyone have some ideas how I can do this?

Any help will be greatly apperciated.

Thank you!
BBkixx


bbkixx

Macro Save with Worksheet as file Name
 
WOW, thank you everyone for the responses. Everything is working very
smoothly now!

BBkixx

"Gary''s Student" wrote:

I don't know how to SaveAs pdf, but the following will SaveAs the sheet or
(tab) name:


Sub Macro1()
Dim s As String
s = ActiveCell.Worksheet.Name
ActiveWorkbook.SaveAs Filename:=s
End Sub

You do not need to spec. the directory if you are willing to save back from
whence you came.
--
Gary's Student


"bbkixx" wrote:

Hello-

I am trying to create a macro that will save a worksheet as a pdf, and
rename the file to the name of the selected worksheet. Now I have the saving
to pdf part down, but I can't seem to get the renaming of the filename to the
worksheet part down. Does anyone have some ideas how I can do this?

Any help will be greatly apperciated.

Thank you!
BBkixx



All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com