limit on number of characters in filename used to oen a document?

Edward Evans 40 Reputation points
2026-04-20T17:31:02.29+00:00

trying to open a document using Word VBA with statement that worked with previous shorter document name, Is there a limit on number of characters allowed in path plus filename touse with Document,Open statement?

Microsoft 365 and Office | Word | For home | Windows
0 comments No comments

1 answer

Sort by: Oldest
  1. AI answer

    2026-04-20T17:31:11.6533333+00:00

    Yes. Word (and other Office applications) have a limit on the total length of the full path plus file name (including the extension) when opening or saving files.

    From the documentation:

    • For Word, PowerPoint, and Access, the total length of the path and file name (including extension) must not exceed 259 characters.
    • For Excel, the total length must not exceed 218 characters.

    This total includes:

    • The drive specification (for example, C:\ – 3 characters)
    • All folder names in the path
    • The backslashes between folders
    • The file name and its extension

    If a Documents.Open call in VBA uses a path that exceeds this limit, Word can fail to open the document and may show errors such as:

    • Filename is not valid.
    • The file could not be accessed.
    • The path you entered, 'filename', is too long. Enter a shorter path.

    To resolve the issue for long paths in VBA:

    • Shorten the file name, and/or
    • Move the document to a folder with a shorter path, and/or
    • Rename one or more folders in the path to shorter names.

    Then update the path used in the Documents.Open statement so that the total length is within the limit.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.