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?
.....
more actions..
End Sub
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