Command Button to Save File Based on Cell Value

yrobbie13

New Member
Joined
Nov 7, 2021
Messages
1
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2010
Platform
  1. Windows
Hi All, I'm hoping for some help please?

Ive been trying to create a button in excel that saves the file for the current workbook with the name as cell value and a path (Sharepoint). below is what i have so far, but doesn't work. HELP PLEASE

Private Sub CommandButton1_Click()
Dim path As String
Dim FileName1 As String
Dim FileName2 As String
path = "https://scotgold.sharepoint.com/SitePages/Home.aspx?RootFolder=/Shared Documents/100 Administration/"
FileName1 = Range("B5")
FileName2 = Range("C5")
ActiveWorkbook.SaveAs FileName:=path & FileName1 & FileName2 & Format(Now(), " DD-MM-YYYY hh_mmAMPM"), FileFormat:=xlOpenXMLWorkbookMacroEnabled


End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
You're not going to be able to use VBA to do much with SharePoint HTTP URLs. If you sync that directory to your computer, you will get the actual folders and files on your computer in File Explorer, and the path will look something like C:\Users\%UserName%\SharePointCompanyName\SharePointFolderPath\.... You can then use this to perform all the operations you need on files & folders.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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