Save as location, cell specific name, save files as pdf and macro enabled file, check for duplicates

lgregory

New Member
Joined
Aug 19, 2014
Messages
3
Hi all,

I'm hoping someone can assist, I've been trying to put together some code from what i've found on here but to no joy.

I'm trying to get some code that will save on a push button to both PDF and Excel macroenabled file at the same time, but prompt to ask where to save it (save as) and to save it from a certain cell for its file name. also for it to check that the file does not already exist.

I'm also curious if there is something that can save to a specific folder depending on month, i.e if I have a folder 2021, and have folders with the months in, that the code would be able to place it in the correct month folder when saving, i'll be honest this isnt important... I was just curious :).

Thanks in advance.
My very poor attempt of bodging someone elses code... please dont judge me lol :

Private Sub CommandButton1_Click()

'
' save Macro


Dim fil As Variant

fil = Application.GetSaveAsFilename(fileFilter:="microsoft excel files (*.xls), *.xls")
If fil <> False Then
MsgBox "File Saved as " & fil

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=Range("m10").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True



End If
Screenshot 2021-04-29 211717.jpg
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,214,965
Messages
6,122,496
Members
449,089
Latest member
Raviguru

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