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
Try to use this command for png file :
WinAPI::shellExecute(_fileName,'','','');
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.
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,134 Super User 2024 Season 2
Martin Dráb 229,928 Most Valuable Professional
nmaenpaa 101,156