hexagon logo

File I/O Command - File Dialog default directory

Objective: When a user completes an inspection routine a file dialog will open allowing a user to choose a (.pdf) report which was previously created. The current inspection results will then be appended to the selected file.

The problem: The native PCDMIS File Dialog command does not allow a user to specify the initial path. The default behavior is to open the most recent used location. This is a problem because the user will need to navigate a rather large and confusing file system rather than having the initial path open where they need to be.

The question: does anyone know where the default (recent) path is stored so I can intervene programmatically and set the File Dialog path to whatever I need? I can not find it in the registry or any .dat or .log files that I've searched.

Using VBScript I have tried invoking a Microsoft Word FileDialog() to accomplish this task and it works how I want except I get a "Server Busy" error stating "This action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the problem". It seems that PCDMIS doesn't like to wait more than a few seconds for the other program (Word) to return a result. I have tried multiple methods to suppress this error but it comes up no matter what I try.

It seems that I need to use the File I/O Command File Dialog but I can't figure out how to direct the "Open" location?

Thanks for looking!
Parents
  • It seems that I need to use the File I/O Command File Dialog but I can't figure out how to direct the "Open" location?


    I don't think you can change that from PC-DMIS. I believe Windows is keeping track of 'last used folder in FileOpenDialog' by itself, and doesn't store it in [the ordinary] Registry.

    I got SHBrowseForFolder to work in PC-DMIS Basic, but that doesn't give you a way to point to a file, only to folders :-(

    Option Explicit
    
    Private Const BIF_RETURNONLYFSDIRS As Long = &H1
    
    Function BrowseFolder(Optional Caption As String, Optional InitialFolder As String) As String
      Dim SH As Object
      Dim F As Object
      Set SH = CreateObject("Shell.Application")
      Set F = SH.BrowseForFolder(0&, Caption, BIF_RETURNONLYFSDIRS,  InitialFolder)
      If Not F Is Nothing Then
        BrowseFolder = F.Items.Item.Path
      End If
    End Function
    
    Sub main()
      MsgBox BrowseFolder ("Caption", "C:\TEMP")
    End Sub
    
  • Nice , but is that the only option for the ulFlags? (BIF_RETURNONLYFSDIRS)
Reply Children
No Data