SaveCopyAs with new filename from two cells

jarzack

New Member
Joined
Jun 14, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I'm still new to learning VBA.

I have a SharePoint that will hold an Excel template. I want to force a user to use SaveCopyAs instead of Save As. I would like for the new filename to come from cells J3, J9 and have a - as a separator. Any suggestions?

Thanks in advance!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hmm. Theoretically user can always SaveAs if he wants. Until you do not block it in some way (VBA doable but on sharepoint? I am too familiar with scripts).
Saving with new filename from based on cells values is not a problem:

Something like:

VBA Code:
Sub SlaintheMhath()

Dim FPath As String, FName As String

    FPath = "C:\Users\UserName\MyFolderSynchronisedWithShareDrive\"    ' User has to have synchronised folder with sharepoint folder

    FName = Range("J3").Value & " " & Range("J9").Value & ".xlsm"

    Application.DisplayAlerts = False

    ActiveWorkbook.SaveCopyAs Filename:=FPath & FName

    Application.DisplayAlerts = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,221,498
Messages
6,160,161
Members
451,627
Latest member
WORBY10

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