Using HYPERLINK to open external files
Many times you may need to open files external to the NAV program. NAV has a built-in function that interacts with the file system to open the file with the appropriate application.
How to do it...
Create a new codeunit from Object Designer.
Add the following global variable:
Name
Type
Selection
Integer
Add the following code to the
OnRun
trigger:Selection := STRMENU('Image,Website'); IF Selection = 1 THEN HYPERLINK('C:\Users\Public\ Pictures\Sample Pictures\Penguins.jpg') ELSE HYPERLINK('HTTP://www.mibuso.com');
Save and close the codeunit.
How it works...
When you run the codeunit you will be presented with a simple selection menu that asks you to choose between an image and a website. Depending on your choice we will use the HYPERLINK
command to load a specific file. This command takes in a single string which points to a location and loads that pointer using the default program on the current machine.
If you choose Image then the Penguins image that...