I was trying to set a vba function that changes the color of a hyperlink when it links to a non existing file. For that, I got the following code on a standard module.

Function FileExist(path As String) As Boolean
    If Dir(path) <> vbNullString Then FileExist = True
End Function

Then I used said function as a conditional formatting for the cells I wanted and it worked as intended.I then saved the file as a macro enabled workbook and closed the program.

When i reopened it, it stopped working. the function was returning false for every imput. The only way i got it to work again was by going to "save as" and saving it again as macro enabled and then refreshing the whole thing .

I verified the trust center and even set to "enable all macros", still it would not work after i reopened the file unless I did the procedure mentioned before.

I have no idea what could be the problem, so i'd appreciate any help. Thanks in advance.

  • Where does the macro reside? PERSONNAL.XLSB? Nov 7, 2018 at 19:30

1 Answer 1


kinda solved it. The problem was that i was verifying local paths with the function. When i opened the file, it didn't manage to find the local path. When i saved it, tho, it was able to recover the file directory and the function started to work again. When i set a remote path, it worked full time.

thanks for the attention

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.