web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Open files from Ax

(0) ShareShare
ReportReport
Posted on by 107

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

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    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.

  • BuBbA Profile Picture
    107 on at

    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
    46,149 on at

    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.

  • Tolstov Dmitrii Profile Picture
    5 on at

    Try to use this command for png file :

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans