Options

Open File from Navision -> user can select the Applicatio

garakgarak Member Posts: 3,263
edited 2011-03-18 in NAV Tips & Tricks
Hy,

when you have saved an file into an Blob (or you have saved the file on your HDD) and you will open it, you can use hyperlink. But hyperlink doesn't support all fileextensions and it will only open the regist. application or this fileextension (for exapmle Notepad for *.TXT) but when you need to open the file with an other Application, the user must have (will have) the chance to select the application he will use. For this case you can use "Standard functionality of windows". So i use the "Open with" Dialog. You must not reg. new DLLs!

Here an example: I've save the file into an Blob. Then i've save the Filename an the extension in semerate fields.
Variables:
Name	DataType	Subtype	Length
FileDialog	Codeunit	Common Dialog Management	
Root	Text		1024
MSCShell	Automation	'Windows Script Host Object Model'.WshShell	

Rec.CALCFIELDS(Attachment);
IF Rec.Attachment.HASVALUE THEN BEGIN
  Root := Rec."Attachment Description" + Rec."Attachment Extension";
  CLEAR(FileDialog);
  Root := FileDialog.OpenFile('Dateipfad...',Root,4,Rec."Attachment Extension" + '|*' + Rec."Attachment Extension",1);
  IF (STRPOS(Root,':\') <> 0) THEN BEGIN
    Rec.Attachment.EXPORT(Root,FALSE);
    IF ISCLEAR(MSCShell) THEN
      CREATE(MSCShell);
    MSCShell.Run('rundll32.exe Shell32,OpenAs_RunDLL ' + Root);
    CLEAR(MSCShell);
  END;
END;

so, have fun with my codeexapmle.

Regards :mrgreen:
Do you make it right, it works too!

Comments

  • Options
    poststationpoststation Member Posts: 17
    Use HYPERLINK, but not one line, you should export it firstly.
    CALCFIELDS(fBlbExtFile);
    IF fBlbExtFile.HASVALUE THEN BEGIN
    lTxtFilePath := STRSUBSTNO('%1\%2',ENVIRON('TEMP'),fTxtFileName);
    lTxtFilePath := fBlbExtFile.EXPORT(lTxtFilePath,FALSE);
    IF lTxtFilePath <> '' THEN
    	HYPERLINK(lTxtFilePath);
    END;
    
    Michael

    Navision Consultant
  • Options
    redhotmustangredhotmustang Member Posts: 91
    I used HYPERLINK (and also tried Shell.RUN) even with a .PNG file and other files located on network folder with no problems on Microsoft Dynamics NAV 2009.
    Redcodestudio: Web Development, FLASH & Webdesign (and a little NAV, in the future)
Sign In or Register to comment.