Opening a Folder - Common Dialog (Simple Solution)

David_CoxDavid_Cox Member Posts: 509
edited 2013-08-08 in NAV Tips & Tricks
I searched the forum for a solution to open a folder from a path in a database field.
There was a couple of answer's saying it was not possible or messy.

If anyone is interested here is a workaround, using a field called "Document folder".

txt:
CommonDialogMgmt.OpenFile(Name,"Document Folder"+'.',1,'',0);

Excel:
CommonDialogMgmt.OpenFile(Name,"Document Folder"+'.',2,'',0);

Word:
CommonDialogMgmt.OpenFile(Name,"Document Folder"+'.',1,'',0);

All Files:
CommonDialogMgmt.OpenFile(Name,"Document Folder"+'.',4,'All Files (*.*)|*.*|All Files (*.*)|*.*',0);

What happens is the commom dialog thinks there is a filename because of the added period in the +'.', and nothing comes up in the Filename on the Windows Dialog screen

C:\Temp\.

No special Automation required, it seems to work ok here, just thought I would share this!

David
Analyst Developer with over 17 years Navision, Contract Status - Busy
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com

Comments

  • Timo_LässerTimo_Lässer Member Posts: 481
    David Cox wrote:
    I searched the forum for a solution to open a folder from a path in a database field.
    There was a couple of answer's saying it was not possible or messy.
    Who say that it is not possible? #-o

    Have a look at these two topics:
    - Select a folder in Navision
    - Get a Folder (Not Reg. new DLLs)
    Timo Lässer
    Microsoft Dynamics NAV Developer since 1997
    MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
  • David_CoxDavid_Cox Member Posts: 509
    David Cox wrote:
    I searched the forum for a solution to open a folder from a path in a database field.
    There was a couple of answer's saying it was not possible or messy.
    Who say that it is not possible? #-o

    Have a look at these two topics:
    - Select a folder in Navision
    - Get a Folder (Not Reg. new DLLs)

    Hi Timo

    I had already read all the the first link and you concluded that is not possible, as in the last reply of that post.

    But reading it again, you was talking about the position in the tree. #-o

    The Second link which I did not get up in my search, has a couple of functions to add, with a few lines of code. :!: Messy

    My work around requires you just to add + '.' to the file path, and I know that any non modification solution would be best for me and my clients, with no additional cost or upgrade issues. :D

    Any Developer reading this on a budgeted fixed price project, would in most cases use the + '.', unless they had over quoted and had a lot of time to use up, which tends not to be the case, add a field that looks up a folder, would not be quoted to much in the analysis. :shock:

    I would not have posted this if I thought that there was a better easy solution, it was posted as when searching I could not find a simple solution, and a small bit of knowledge shared might save someone else some time. =D>

    If you can come up with a solution in less that 4 letters, please let me know :-k

    I have renamed the thread, adding Simple Solution!

    Regards

    David

    K.I.S.S ](*,)
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • arcullarcull Member Posts: 191
    Check this:


    OpenFolder(WindowTitle : Text[50];HighestFolder : Text[500]) : Text[1024]
    IF ISCLEAR(ShellControl) THEN
    CREATE(ShellControl);

    Folder := ShellControl.BrowseForFolder(0,WindowTitle,0,HighestFolder);
    IF NOT ISCLEAR(Folder) THEN
    FolderText := Folder.Items().Item.Path;
    CLEAR(ShellControl);
    EXIT(FolderText);

    the variables required are:
    Var Name DataType Subtype Length
    No WindowTitle Text 50
    No HighestFolder Text 500

    Name DataType Subtype Length
    ShellControl Automation 'Microsoft Shell Controls And Automation'.Shell
    Folder Automation 'Microsoft Shell Controls And Automation'.Folder3
    FolderText Text 1024
  • ASTAST Member Posts: 108
    Hello,
    I just found this solution (arcull code). Taht's great, but when I choose desktop I get the message for C/AL programmers that autmation variable has not been instantiated.
    I know that my client first click Desktop ikon.
  • absolutelyfreewebabsolutelyfreeweb Member Posts: 104
    Hmm... maybe it worked before, but with win 7 and 2009 R2 classic the dot trick does not work.
Sign In or Register to comment.