Macro Posting to Sharepoint

Sproe221

New Member
Joined
Aug 6, 2019
Messages
1
Hi Mr. Excel,

Thank you for reading my post! Long time lurker, first time poster.



The code below is meant to save a file as two different naming conventions and save each to a different Sharepoint site. The issue that has arisen is that this workedeven last week, but now it is telling me Path not found for all the paths I try. I have pasted the paths into my browser andconfirmed that they opened the right page with no trouble, so I don’t know whatelse to test. All answers about postingto Sharepoint use the CopyFile FromPath ToPath method, but that’s the one thatis now giving me (and my team when they test) issues.

I understand that my code doesn’t include the actual websitepaths, but I assure you that they do work when pasted into my browser, and theyworked in the past, so I’m trying to determine if the actual method is theproblem.



Code:
Sub SharePointExport()


    

    'Saves the file to the appropriate sharepoint site based on the region


Dim objOutlookMsg As Object

Dim OperatingUnit As String

Dim FSO As Object

Dim FromPath As String

Dim ToPath As String

Dim MSBPathCheck As String

Dim RegionPathCheck As String

Dim FilePath As String

Dim Sheet_Password As String

 

FromPath = ThisWorkbook.FullName

MSBPathCheck = Range("MSBPathCheck").value

RegionPathCheck = Range("RegionPathCheck").value

  Set OutApp = Nothing

  Set objOutlookMsg =Nothing

 

OperatingUnit = Range("Oper_Unit").value

 

 

  'MSB Upload

     If ActiveWorkbook.Sheets("Settings").Range("SharePointURLMSB")<> "No URL" Then

            ToPath =Range("ToPath").value & Range("MSBUploadName").value

           Set FSO =CreateObject("scripting.filesystemobject")

           

    FSO.CopyFileSource:=FromPath, Destination:=ToPath

 

    End If

    

‘RegionUpload:

     If ActiveWorkbook.Sheets("Settings").Range("SharePointURLMSB")<> "No URL" Then

            ToPath =Range("RegionalUploadName").value

           Set FSO =CreateObject("scripting.filesystemobject")

    FSO.CopyFileSource:=FromPath, Destination:=ToPath

    End If

ThisWorkbook.Saved = True

 

Exit Sub

End Sub



 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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