Finding a Sharepoint folder

vimilac

New Member
Joined
Feb 11, 2011
Messages
8
Hello All - I have a workbook macro that will not work... I've looked at other threads here, and other sites, and just can't crack the problem. The workbook is a "template" for a purchase requisition. After modification the code will assign a name and "SaveAs" into a SharePoint folder named for the current year. The directory containing the template also contains a folder named "Requisitions", which contains subfolders corresponding the years. The original code worked fine until our IT people updated to Windows 10. Now, the script can't find the path to the folder. I have WEBDAV enabled on my workstation, and project refences are checked for M/s scripting runtime and Windows script host object model. I'm sort of at a deadend as to what to try next - any ideas?

VBA Code:
Private Sub Save_File_Click()
'
'
Dim Req_Path As String
Dim CurrentYearReqFolder As Folder
Dim CurrentYearFolderPath As FileSystemObject

'
    'Initialize variables:
J = 0
Auto_Fill = False
'
Req_Path = Environ$("userprofile") & "\\SharePoint\###\####\Shared%20Documents\####\Requisitions"
Set CurrentYearFolderPath = New FileSystemObject
'*** this code will not locate the folder in the statement below even though the folder does in fact exist ***
Set CurrentYearReqFolder = CurrentYearFolderPath.GetFolder(Req_Path & "\" & VBA.Year(VBA.Date))
'*** since the file folder already exists, the code will not skip past the "IF" block below ***
    'check that a file folder named for the current year exists:
If CurrentYearReqFolder is Nothing Then 'Create a new directory for the current year
    CurrentYearFolderPath.CreateFolder (Req_Path & "\" & VBA.Year(VBA.Date))
    MsgBox "A new directory in the requisitions folder has been created for this year", vbOKOnly + vbInformation, "Anodize Shop Expenses"
End If
'
'Now, validate the inputs
.....
more actions..

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
Found what appears to be the answer.. I had a DIM statement listing 'CurrentYearReqFolder' as a folder which threw a type-mismatch error. So I changed it to list as an object. Additionally, I got rid of the 'Environ' business prefixing the address and changed all the space characters (%20's) into just spaces. But thanks for reading!
 
Upvote 0
Solution

Forum statistics

Threads
1,213,535
Messages
6,114,194
Members
448,554
Latest member
Gleisner2

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