Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro save a file name from a cell in 1st worksheet | Excel Discussion (Misc queries) | |||
file size after using macro to save a worksheet | Excel Programming | |||
How do I set up a macro to save an Excel worksheet as a .prn file? | Excel Programming | |||
Macro to export a worksheet and save as new file | Excel Programming | |||
using macro to save worksheet with unique file name | Excel Programming |