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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,054
Messages
6,122,901
Members
449,097
Latest member
dbomb1414

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