Word 2010 & VBA & Run-time Error 5487

tzw1378

Active Member
Joined
Jan 16, 2014
Messages
270
Hello,

This is a question related to Word 2010. If a moderator sees this and deems it inappropriate for this forum, I understand. In such a case, please remove immediately.

I've searched extensively but haven't found a way to correct this run-time error 5487 which is indicating a file permission error.

Code:
        ChangeFileOpenDirectory FoldertoSaveIn
        DocName = ActiveDocument.Paragraphs(4).Range
        ActiveDocument.SaveAs2 FileName:=DocName & " " & Format(Now, "dd-mm-yyyy hh.mm.ss") & ".docx", FileFormat:=wdFormatDocumentDefault
        ActiveDocument.Close

The above code doesn't work and I can't determine how to fix it.

Thank you in advance for your help.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Thank you all for viewing this and to Brian for his reply. While I didn't see a link in Brian's thread, I write now to let you know that I worked around the issue. For some reason, it didn't agree with how I was setting "DocName." While I still used the above "Paragraphs(4)" reference, in the next line I did:

Code:
sDocName = CStr(Trim(Left(sDocName, 9))) & " "

As shown, it desperately needed to be converted to a string!

Have a great day.
 
Upvote 0
Thank you all for viewing this and to Brian for his reply. While I didn't see a link in Brian's thread, I write now to let you know that I worked around the issue. For some reason, it didn't agree with how I was setting "DocName." While I still used the above "Paragraphs(4)" reference, in the next line I did:

Code:
sDocName = CStr(Trim(Left(sDocName, 9))) & " "

As shown, it desperately needed to be converted to a string!

Have a great day.

Yeah that's basically what the link was. Making sure it's a proper string.
 
Upvote 0

Forum statistics

Threads
1,214,658
Messages
6,120,778
Members
448,992
Latest member
prabhuk279

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