VBA code to Save a copy of the new tab to a Sharepoint site

VBA learner ITG

Active Member
Joined
Apr 18, 2017
Messages
267
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Thank you for reading my post.

I was wondering if anyone could advise me or point me in the right direction on the below issue I am having.

I have the below VBA code to create a new project Tab within the project document which is saved on my Mac desktop. However I am looking for a piece of VBA code that will allow me to save a copy of the new tab thats created to a Sharepoint site with the same name thats created as part of the below VBA code.

Also is there a way to either link the saved/newly created tab to the saved doc on the sharepoint site to update when new data is inputted into the tab or when it saved it will refresh the data?

IS it at all possible as i'm using Office 365 for Mac.


Sub Copy_paste_tab()


Range("D5").Select
ExecuteExcel4Macro _
"FORMULA.REPLACE("" "",""_"",2,1,TRUE,FALSE,,FALSE,FALSE,FALSE,FALSE)"
Cells.Find(What:=" ", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
.Activate


Range("A1").Select


Dim ws As Worksheet
Set wh = Worksheets(ActiveSheet.Name)
ActiveSheet.Copy After:=Worksheets(Sheets.Count)
If wh.Range("D5").Value <> "" Then
ActiveSheet.Name = wh.Range("D5").Value
End If
wh.Activate


End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi again,

I found the below code from another forum which another user has managed to save to a Sharepoint site.

However i have tried to replicate the code and getting an error message.


can anyone help with why it doesn't work for me :(

Sub Sharepoint()
'
' Sharepoint Macro


Dim docCheckOut As String
docCheckOut = "https://inspiredthinkinggroupltd.sharepoint.com/sites/ZackProjectCalendar/_layouts/15/guestaccess.aspx?guestaccesstoken=qFRflbg%2b1m22xkSWpCHs7LNrhGz5iJ46CpvnWt41%2baQ%3d&folderid=2_1e8220f7637f54085b2d8b6820c9799fe&rev=1"
Call UseCheckOut(docCheckOut)


End Sub


Sub UseCheckOut(docCheckOut As String)
' Determine if workbook can be checked out.
If Workbooks.CanCheckOut(docCheckOut) = True Then
Workbooks.CheckOut docCheckOut
Else
MsgBox "Unable to check out this document at this time."
End If
End Sub


End Sub
 
Upvote 0
I have another variance of a code that seem to work up to a point of it doesn't like the save object error message:

any advice possible would be appreciated.


Sub Save()
'
' Save Macro


MName = ActiveSheet.Name & ".XLSM"
MDir = ActiveWorkbook.Path
ActiveWorkbook.SaveAs Filename:="https://inspiredthinkinggroupltd.sharepoint.com/sites/ZackProjectCalendar/_layouts/15/guestaccess.aspx?guestaccesstoken=qFRflbg%2b1m22xkSWpCHs7LNrhGz5iJ46CpvnWt41%2baQ%3d&folderid=2_1e8220f7637f54085b2d8b6820c9799fe&rev=1"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,853
Members
449,194
Latest member
HellScout

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