Error Message Since Moving to Windows 10

tomexcel1

New Member
Joined
Feb 22, 2018
Messages
47
Hi All,

I have been using the below code for a few years now. It basically saves the tabs of workbook as individual files when a button is pressed.

Since moving to windows 10 the code gets the following error: Run-time error '76': Path not found. It indicates the error happens on "MkDir FolderName"
Does anyone have any idea why its doing this since moving to windows 10?

VBA Code:
Sub SaveBatches()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim xWs As Worksheet
Dim xWb As Workbook
Dim FolderName As String
Application.ScreenUpdating = False
Set xWb = Application.ThisWorkbook
DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")
FolderName = xWb.Path & "\" & xWb.Name & " " & DateString
MkDir FolderName
ThisPeriod = Application.InputBox("Please Enter Date in the format DD-YY", "Current Date", "DD-YY")
For Each xWs In xWb.Worksheets
    xWs.Copy
    If Val(Application.Version) < 12 Then
        FileExtStr = ".xls": FileFormatNum = -4143
    Else
        Select Case xWb.FileFormat
            Case 51:
                FileExtStr = ".xlsx": FileFormatNum = 51
            Case 52:
                If Application.ActiveWorkbook.HasVBProject Then
                    FileExtStr = ".xlsm": FileFormatNum = 52
                Else
                    FileExtStr = ".xlsx": FileFormatNum = 51
                End If
            Case 56:
                FileExtStr = ".xls": FileFormatNum = 56
            Case Else:
                FileExtStr = ".xlsb": FileFormatNum = 50
        End Select
    End If
    xFile = FolderName & "\" & "Report Name Report " & ThisDate & " - BATCH" & Application.ActiveWorkbook.Sheets(1).Name & " (" & ActiveWorkbook.Sheets(1).Range("B2").Value & ")" & FileExtStr
    Application.ActiveWorkbook.SaveAs xFile, FileFormat:=FileFormatNum
    Application.ActiveWorkbook.Close False
Next
MsgBox "You can find the files in " & FolderName
Application.ScreenUpdating = True
End Sub

Thanks in Advance
Tom
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Are you by any chance running it on OneDrive or Sharepoint ?
Worked fine for me on my C Drive but crashed on OneDrive.
 
Upvote 0
Hi Alex,

Yes that might be it, it normally is saved on the desktop but windows 10 desktop is on OneDrive. Can you think of a way of fixing it?

Thanks
Tom
 
Upvote 0
You cannot run macros/vba on OneDrive. OneDrive does not support VBA.
You can store files with VBA code on OneDrive, but if you want to run the code, you will need to download the file to your computer first.
 
Upvote 0
Solution
You are welcome.
Glad we were able to help.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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