Saving files to a folder created by a Macro

abdulrahman1

New Member
Joined
Feb 8, 2018
Messages
8
Hi all,

I am using a macro to create a folder. This is working perfectly. However, when I try to save something into that newly created file, I get a popup saying

"The file could not be accessed. Try one of the following..."

This is the macro used to create the new folder

Sub CreateORFolder()


'Variable definations
Dim ORFilesParentFolderPath As String
Dim ORFilesFolder As String


'Set the Folder where the individual folders should be created


ORFilesParentFolderPath = Range("C19").Value
ORFilesFolder = Range("E19").Value


If FileSystem.Dir(ORFilesFolder, vbDirectory) = vbNullString Then
FileSystem.MkDir ORFilesFolder
Else
MsgBox "Daily OR folder already exists. No action has been taken"
End If


End Sub

I'm on Excel 2007
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
How are you saving the files?
 
Upvote 0
Manually via 'Save As' Excel Workbook (.xlsx).

I have just encountered another issue which I think are related. I have another Macro which goes into this folder and opens up a file. But despite the fact that the file was there (I saved it elsewhere and copied it in to the directory), the Macro would bring up the same error message that I received when trying to save the file in the earlier query!
 
Upvote 0
Open a file from that directory & try to Save, will it let you?
 
Upvote 0
It won't allow me to save. I'm baffled as I can copy excel files into that directory. I tried saving documents into that directory with another program, that worked. I then opened the file and tried to save, that also worked! but through excel - it will not work.
 
Upvote 0
I don't understand why you can save to that folder from one app but not another.
Can you save a test file as a .csv to that folder from excel?
 
Upvote 0
Apologies for the delayed response but I got to the bottom of this. The reason the macro would not open the file is because the character length of the cell it was referencing was more than 256!!

Thanks
 
Upvote 0
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

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