Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Open files from Ax

Posted on by 105

Hi,

We have a requirement where we want to open files directly from in Ax. The files we want to open have different file types (PDF, PNG, ...).

I found and used the following command to open files:

WinAPI::shellExecute(_fileName,'','',#ShellExeOpen);

This command seems to work fine for certain files (like PDF) but it doesn't work for other types (like PNG for example).

When i open the file directly from windows, the PNG file opens in Paint. But when i open it with the command stated above, i get the error:

"The file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel."

I don't understand this message, since the type PNG is already linked to a default program and it opens fine when i do it in windows file explorer.

Can i somehow do the same from in Ax?

*This post is locked for comments

  • Tolstov Dmitrii Profile Picture
    Tolstov Dmitrii 5 on at
    RE: Open files from Ax

    Try to use this command for png file :

    WinAPI::shellExecute(_fileName,'','','');

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Open files from Ax

    Then you do not have PNG files associated indeed, like the error message says.

    By default, Windows kernel opens it within Internet Explorer, but that is most likely not a traditional default file extension match.

    Try installing a picture viewer custom software that supports file extension association based on the registry, then attempt calling the process start.

  • BuBbA Profile Picture
    BuBbA 105 on at
    RE: Open files from Ax

    I tried using it that way, but the same result: PDF files are being opened but PNG files do nothing. I am not getting any errors or anything, it just doesn't do anything.

    Edit: I forgot catching the CLR error. Now i get the same error as i do when using WinApi::ShellExecute. No application is associated with the specified file for this operation. But as i said before, the default for PNG has been set so i don't understand the error.

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Open files from Ax

    It is fully supported to use the .Net namespace in AX, you may call it in a similar way to this C# example:

    stackoverflow.com/.../open-file-with-associated-application

    You have to make sure that there is an associated default program indeed for the file extension, because some file types might be handled by the Windows kernel itself.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,134 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans