Microsoft Visual Basic Runtime error 1004: Document not saved, The document may be open, or an error may have been encountered when saving

Anonymous
2022-02-21T08:35:28+00:00

Hello,

I've got a issue with my Macros in Excel in my PC only.

It worked just fine before and it still works on another pc with both Win 7 & Win 10, however it does not on my PC.

I have done clean installation of Win 10, at start it works fine. After few days and recent Windows update it again started throwing an error.

When I try to run excel with macro "ExportAsFixedFormat xlTypePDF", it throws an error and highlights this area when I press Debug: as shown in images.

The error thrown line is as below

Range("A1:I48").ExportAsFixedFormat xlTypePDF, Environ("Userprofile") & "\Desktop\PrintPDF.pdf"

here I am trying to export a certain range in PDF format.

Kindly Help. As I cannot clean install again and again.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Anonymous
    2022-02-23T12:00:19+00:00

    Did you try changing the saving location from saving it to the user folder to some other folder? If not tried yet, please try and see.

    0 comments No comments