Run-Time error '1004':

Numburz

New Member
Joined
Jul 12, 2015
Messages
6
Have some code that should determine users My Documents path, Create a New Folder in their documents, then save a newly created PDF document in that folder.

It runs fine on my system. When other users try to run it, they are getting:

Run-time error '1004':

Document not saved. The document may be open, or an error may have been encountered when saving. When Debug is clicked, it points to the code that simply saves the file in the prescribed path as a pdf. As indicated, it works fine on my system but causes this issue for other users.

Here is an image of the code and the portion that is highlighted on debug. I think it may have something to do with the interaction of the Function but I'm baffled.

Any assistance is greatly appreciated.

Generate_Sub.jpeg
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
It simply has a formula that uses information from different portions of the workbook to generate a unique file name. In the subject case it happens to read:

GSC-Adjustment-Advance-453621-2015-26-none-Smith-Mike.pdf
 
Upvote 0
I admit I am guessing here but should it not be ......& "\Salary Advances\" not .....& "/Salary Advances/"
 
Upvote 0
I originally had it that way, however, it would not work for me. When I made the changes it works for me without any errors and generates the necessary forms. It is only when I send the file to another user, that is generates the run-time error.
 
Upvote 0
should you not be saving the active workbook? not worksheet?

I have nothing more...LOl experts........stand to.
 
Upvote 0
In this case, no, I only need to save the specific worksheets to a pdf file. I do not need to save the workbook.
 
Upvote 0
Who has the workbook because when the macro runs for another person it will be their username as you have set it to Environ(username) which will be whoever has the file open at the time so it is looking to file it in their documents is that right?
 
Upvote 0
Correct, that is exactly what I want. When any user opens the file, the function should identify their documents folder. I then have it coded to create a new folder in their documents called Salary Advances. Finally, it should create and save the prescribed PDF file in that new folder, or at least that was the theory I was operating with. It does this on my system, just can't get it to function on other users. I've had them save the workbook with the same file name and it still won't work. I've had them create the Salary Advance folder manually thinking that may be the source. That too did not work...
 
Upvote 0
Sorry mate,

That's me done.... I thought I had found the golden nugget with the username!!!! especially as they have manually created the folder as well
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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