Link to home
Create AccountLog in
Avatar of gregholl
greghollFlag for Ecuador

asked on

having troubles with an Excel Macro saving to C: on Windows 10

I have this certain file from the Bank to do payroll stuff. (Very hokey but I won't get in to that).

At the end of the process, I invoke a Macro that saves certain data to a folder on the C: Drive.

The macro always gives the following error:
User generated image
I'm suspecting that there is some kind of security issue going on that I cannot save to the C: drive. If so, please how can I circumvent that.

-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  

As an FYI, here is a screenshot of the area of the macro that causes the problem. The particular folder in question, namely "C:/Produbanco/" is indeed set up.

User generated image
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  

I've had several very frustrating talks on the phone with the support people at the bank to no avail.

Please help. Thanks! :D
Avatar of CompProbSolv
CompProbSolv
Flag of United States of America image

Make sure that dirCambio is a proper string for a full file spec.  I'd display it in a message box surrounded by <> to confirm that it is what you expect and doesn't have any spaces or other issues.
Avatar of gregholl

ASKER

Hi. There is no problem with the Macro itself. This was not made by me. I would rather not mess with it. This exact same Excel document works just fine on my old computer which was running Windows Server Edition 2012. I transfer the Excel file to the new computer under Windows 10, and the macro gets this error.

How do I make it so that, by default, the macro can save things to the C:  drive?
Hi Greg,
What is in the variable nomArch and what is its type? Note that + is being used as the concatenation operator rather than &. Regards, Joe
Joe Winograd: Please let's not deal with the syntax of the macro. It's fine, because it works on other computers. I honestly think, as mentioned before, that I need to activate the C: drive somehow to allow writing to it without any security warning.

Thanks Joe, but I really don't think we need to get into macro syntax and I don't really understand it anyway.
Greg,
You said in the original question, "The particular folder in question, namely "C:/Produbanco/" is indeed set up." The point is, that is not the folder in question. The folder in question is the concatenation of C:\Produbanco\ (I fixed your forward slashes to backslashes) with whatever is in the variable nomArch. So the subfolder that it is trying to write to may, indeed, not exist on your new computer, but does exist on your old computer. Hence, it throws the "Path/File access error" on the new computer but not the old one. Go to your old computer and look at the subfolders of C:\Produbanco\ — make sure they exist on the new computer, and if not, create them. Regards, Joe
Sorry about the slashes.

Here's some screen shots from the old computer.

a) I deleted the folder called C:\Produbanco\ just for this exercise. I try to run the Macro. I get this error:
User generated image(It says: "Produbanco folder doesn't exist; please create it).

b) So I make the folder, as requested. No sub folder or anything.
User generated image
c) Now I run the macro again, and it works just fine.
User generated image(It says: "The Provider payment file was successfully created at C:\Produbanco\pagos fin sep.txt)

-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  

regarding nomArch and the concatenation:
The macro works like this. I put in a certain cell the name I want the file to have. It this case, I entered the text:  "pagos fin sep". Then the concatenate puts it all together and I get: C:\Produbanco\pagos fin sep.txt

I don't honestly know what nomArch means but I figure that it's taking the name I put in from that particular cell.

-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  

Now.... replay with this exact same Excel document, on the same version of Excel, but on the new computer and I get the error as shown in the original question.

Hope that sheds some light to be able to troubleshoot this issue.
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Yup. That did it. All fine now. sooooo. happy!  ;)

Thanks
Sorry...away from the computer for a while.

> I don't honestly know what nomArch means

Well, if the concatenation is resulting in C:\Produbanco\pagos fin sep.txt, then nomArch is obviously the file name, not a subfolder.

I thought you wanted to get it working on the C: drive ("I would rather not mess with it [the macro]"), but if you're OK with changing the macro to work on D: (or E: or H: or whatever), that's great. Still doesn't answer the question of why it's not working on C: — but if you're happy, that's all that matters. And I was happy to try to help you. Regards, Joe