Hoping this is only a slight vba tweak needed.

123rickfear

Active Member
Joined
Jun 19, 2015
Messages
446
Hi all,

I would like to be able to save a filename directly to our sharepoint.

However, when I run the macro I get an error message from the upload center saying the path is not found.

below is my code. Please can someone help me.


Code:
Sub SubmitAandAData()
Dim Sh As Worksheet
Dim folder As String
Dim filename As String
Application.DisplayAlerts = False
Worksheets("DataEntry").Range("A1:Z500").Copy
Worksheets("DataEntry").Range("A1").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
For Each Sh In Worksheets
If Sh.Name <> "DataEntry" Then Sh.Delete
Next
Application.DisplayAlerts = True
filename = "[URL]https://xxxxxxxxxx.sharepoint.com/teams/grouphr/hrsystems/Absence%20and%20Attendance/Forms/AllItems/[/URL]" & Range("B3") & Range("B5") & ".xlsm"
     
    ActiveWorkbook.SaveAs filename
  
    Application.DisplayAlerts = True
    
    ActiveWorkbook.Close
MsgBox "Saved"
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
123rickfear,
You might clarify what values are in B3 and B5...However, it could be the way you refer to the two Ranges, B3 and B5 in this line of code:

Code:
filename = "[URL]https://xxxxxxxxxx.sharepoint.com/te...orms/AllItems/[/URL]" & Range("B3") & Range("B5") & ".xlsm"

Assuming those 'values' require no separation or separator such as '/', then this should work:

Code:
filename = "[URL]https://xxxxxxxxxx.sharepoint.com/te...orms/AllItems/[/URL]" & Range("B3").value & Range("B5").value & ".xlsm"

'OR... 
filename = "[URL]https://xxxxxxxxxx.sharepoint.com/te...orms/AllItems/[/URL]" & cells(3,"B") & cells(5,"B") & ".xlsm"

The 'cells' format defaults to the 'value'...the 'Range' format requires the clarification of 'value', or 'address' or whatever.
Perpa
 
Last edited:
Upvote 0
I don't believe that you can use the SaveAs method to save to an "HTTP://" site.
You'll need to find out the actual server name and share name.
 
Upvote 0
Our sharepoint is cloud based, so doesn't have a server address.

I need to save a file to a location, but don't want people to be able to access that location (unless they have permission).

Any suggestions?
 
Upvote 0
AFAIK if you don't have access permission to a site, then you cannot save to it.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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